@zapier/zapier-sdk-cli 0.62.0 → 0.64.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 +26 -0
- package/README.md +42 -42
- package/dist/cli.cjs +367 -51
- package/dist/cli.mjs +369 -53
- 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 +364 -43
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +366 -45
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -990,6 +990,39 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
990
990
|
return getBaseUrlFromResolvedCredentials(resolvedCredentials) ?? getBaseUrlFromOptionsCredentials(context.options?.credentials) ?? context.options?.baseUrl;
|
|
991
991
|
}
|
|
992
992
|
|
|
993
|
+
// src/utils/cli-argument-sanitizer.ts
|
|
994
|
+
var SENSITIVE_FLAGS = [
|
|
995
|
+
"--credentials",
|
|
996
|
+
"--credentials-client-secret",
|
|
997
|
+
"--credentials-client-id",
|
|
998
|
+
"--credentials-base-url",
|
|
999
|
+
"--callback-url",
|
|
1000
|
+
"--user",
|
|
1001
|
+
"--header",
|
|
1002
|
+
"-H",
|
|
1003
|
+
"-u"
|
|
1004
|
+
];
|
|
1005
|
+
function sanitizeCliArguments(args) {
|
|
1006
|
+
const sanitized = [];
|
|
1007
|
+
let skipNext = false;
|
|
1008
|
+
for (const arg of args) {
|
|
1009
|
+
if (skipNext) {
|
|
1010
|
+
skipNext = false;
|
|
1011
|
+
sanitized.push("[REDACTED]");
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
if (SENSITIVE_FLAGS.some((flag) => arg.startsWith(flag + "="))) {
|
|
1015
|
+
sanitized.push(arg.split("=")[0] + "=[REDACTED]");
|
|
1016
|
+
} else if (SENSITIVE_FLAGS.includes(arg)) {
|
|
1017
|
+
sanitized.push(arg);
|
|
1018
|
+
skipNext = true;
|
|
1019
|
+
} else {
|
|
1020
|
+
sanitized.push(arg);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return sanitized;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
993
1026
|
// src/utils/non-interactive.ts
|
|
994
1027
|
function resolveNonInteractive(options) {
|
|
995
1028
|
return options.nonInteractive === true || options.skipPrompts === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
@@ -1309,6 +1342,14 @@ var client_default = api;
|
|
|
1309
1342
|
|
|
1310
1343
|
// src/utils/auth/oauth-transaction.ts
|
|
1311
1344
|
var OAUTH_LOOPBACK_HOST = "localhost";
|
|
1345
|
+
var OauthTransactionSchema = zod.z.object({
|
|
1346
|
+
browserAuthUrl: zod.z.string(),
|
|
1347
|
+
clientId: zod.z.string(),
|
|
1348
|
+
codeVerifier: zod.z.string(),
|
|
1349
|
+
redirectUri: zod.z.string(),
|
|
1350
|
+
state: zod.z.string(),
|
|
1351
|
+
tokenUrl: zod.z.string()
|
|
1352
|
+
});
|
|
1312
1353
|
function buildBrowserAuthUrl({
|
|
1313
1354
|
authorizeUrl,
|
|
1314
1355
|
entryPoint = "login"
|
|
@@ -1397,8 +1438,51 @@ async function exchangeOauthCode({
|
|
|
1397
1438
|
expiresIn: data.expires_in
|
|
1398
1439
|
};
|
|
1399
1440
|
}
|
|
1441
|
+
var PENDING_OAUTH_TRANSACTION_KEY = "pending_oauth_transaction";
|
|
1442
|
+
var PendingOauthTransactionSchema = zod.z.object({
|
|
1443
|
+
version: zod.z.literal(1),
|
|
1444
|
+
entryPoint: zod.z.enum(["login", "signup"]),
|
|
1445
|
+
expiresAt: zod.z.number(),
|
|
1446
|
+
credentialsBaseUrl: zod.z.string().optional(),
|
|
1447
|
+
credentialName: zod.z.string().optional(),
|
|
1448
|
+
useApprovals: zod.z.boolean(),
|
|
1449
|
+
headless: zod.z.boolean().default(false),
|
|
1450
|
+
transaction: OauthTransactionSchema
|
|
1451
|
+
});
|
|
1452
|
+
function savePendingOauthTransaction({
|
|
1453
|
+
entryPoint,
|
|
1454
|
+
transaction,
|
|
1455
|
+
expiresAt,
|
|
1456
|
+
credentialsBaseUrl,
|
|
1457
|
+
credentialName,
|
|
1458
|
+
useApprovals,
|
|
1459
|
+
headless
|
|
1460
|
+
}) {
|
|
1461
|
+
const pendingTransaction = {
|
|
1462
|
+
version: 1,
|
|
1463
|
+
entryPoint,
|
|
1464
|
+
expiresAt,
|
|
1465
|
+
useApprovals,
|
|
1466
|
+
headless,
|
|
1467
|
+
transaction,
|
|
1468
|
+
...credentialsBaseUrl !== void 0 && { credentialsBaseUrl },
|
|
1469
|
+
...credentialName !== void 0 && { credentialName }
|
|
1470
|
+
};
|
|
1471
|
+
getConfig().set(PENDING_OAUTH_TRANSACTION_KEY, pendingTransaction);
|
|
1472
|
+
return pendingTransaction;
|
|
1473
|
+
}
|
|
1474
|
+
function getPendingOauthTransaction() {
|
|
1475
|
+
const result = PendingOauthTransactionSchema.safeParse(
|
|
1476
|
+
getConfig().get(PENDING_OAUTH_TRANSACTION_KEY)
|
|
1477
|
+
);
|
|
1478
|
+
return result.success ? result.data : void 0;
|
|
1479
|
+
}
|
|
1480
|
+
function clearPendingOauthTransaction() {
|
|
1481
|
+
getConfig().delete(PENDING_OAUTH_TRANSACTION_KEY);
|
|
1482
|
+
}
|
|
1400
1483
|
|
|
1401
1484
|
// src/utils/auth/oauth-flow.ts
|
|
1485
|
+
var PENDING_OAUTH_RECOVERY_MESSAGE = "Start a new non-interactive login or signup flow to generate a fresh URL.";
|
|
1402
1486
|
var LOGIN_OAUTH_COPY = {
|
|
1403
1487
|
flowName: "Login",
|
|
1404
1488
|
action: "log in",
|
|
@@ -1454,6 +1538,95 @@ async function runSignupOauthFlow(options) {
|
|
|
1454
1538
|
copy: SIGNUP_OAUTH_COPY
|
|
1455
1539
|
});
|
|
1456
1540
|
}
|
|
1541
|
+
async function startPendingOauthFlow({
|
|
1542
|
+
timeoutMs = LOGIN_TIMEOUT_MS,
|
|
1543
|
+
pkceCredentials,
|
|
1544
|
+
baseUrl,
|
|
1545
|
+
entryPoint,
|
|
1546
|
+
credentialName,
|
|
1547
|
+
useApprovals,
|
|
1548
|
+
headless
|
|
1549
|
+
}) {
|
|
1550
|
+
const copy = entryPoint === "signup" ? SIGNUP_OAUTH_COPY : LOGIN_OAUTH_COPY;
|
|
1551
|
+
const port = LOGIN_PORTS[0];
|
|
1552
|
+
const transaction = await prepareOauthTransaction({
|
|
1553
|
+
pkceCredentials,
|
|
1554
|
+
baseUrl,
|
|
1555
|
+
redirectUri: `http://${OAUTH_LOOPBACK_HOST}:${port}/oauth`,
|
|
1556
|
+
entryPoint
|
|
1557
|
+
});
|
|
1558
|
+
const pending = savePendingOauthTransaction({
|
|
1559
|
+
entryPoint,
|
|
1560
|
+
transaction,
|
|
1561
|
+
expiresAt: Date.now() + timeoutMs,
|
|
1562
|
+
credentialsBaseUrl: baseUrl,
|
|
1563
|
+
credentialName,
|
|
1564
|
+
useApprovals,
|
|
1565
|
+
headless
|
|
1566
|
+
});
|
|
1567
|
+
process.stderr.write(
|
|
1568
|
+
`Open this ${copy.urlLabel} in a browser to continue:
|
|
1569
|
+
`
|
|
1570
|
+
);
|
|
1571
|
+
console.log(transaction.browserAuthUrl);
|
|
1572
|
+
if (!headless) {
|
|
1573
|
+
process.stderr.write(`Opening your browser to ${entryPoint}.
|
|
1574
|
+
`);
|
|
1575
|
+
try {
|
|
1576
|
+
await open__default.default(transaction.browserAuthUrl);
|
|
1577
|
+
} catch (error) {
|
|
1578
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1579
|
+
process.stderr.write(
|
|
1580
|
+
`Browser did not open automatically to ${entryPoint}: ${reason}
|
|
1581
|
+
`
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
process.stderr.write(
|
|
1586
|
+
`After authorizing, finish with \`zapier-sdk ${entryPoint} --callback-url <final-url>\`.
|
|
1587
|
+
`
|
|
1588
|
+
);
|
|
1589
|
+
return pending;
|
|
1590
|
+
}
|
|
1591
|
+
function getPendingOauthFlow({
|
|
1592
|
+
entryPoint
|
|
1593
|
+
}) {
|
|
1594
|
+
const pending = getPendingOauthTransaction();
|
|
1595
|
+
if (!pending) {
|
|
1596
|
+
throw new ZapierCliValidationError(
|
|
1597
|
+
`No pending ${entryPoint} OAuth flow found. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
|
|
1598
|
+
);
|
|
1599
|
+
}
|
|
1600
|
+
if (Date.now() > pending.expiresAt) {
|
|
1601
|
+
clearPendingOauthTransaction();
|
|
1602
|
+
throw new ZapierCliValidationError(
|
|
1603
|
+
`Pending ${pending.entryPoint} OAuth flow has expired. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
if (pending.entryPoint !== entryPoint) {
|
|
1607
|
+
throw new ZapierCliValidationError(
|
|
1608
|
+
`Pending OAuth flow is for ${pending.entryPoint}, not ${entryPoint}. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
return pending;
|
|
1612
|
+
}
|
|
1613
|
+
async function resumePendingOauthFlow({
|
|
1614
|
+
pending,
|
|
1615
|
+
callbackUrl,
|
|
1616
|
+
onProgress
|
|
1617
|
+
}) {
|
|
1618
|
+
const code = getCallbackCode({
|
|
1619
|
+
callbackUrl,
|
|
1620
|
+
transaction: pending.transaction
|
|
1621
|
+
});
|
|
1622
|
+
onProgress?.({ type: "callback_accepted" });
|
|
1623
|
+
process.stderr.write("Exchanging authorization code for tokens...\n");
|
|
1624
|
+
onProgress?.({ type: "token_exchange_started" });
|
|
1625
|
+
const tokens = await exchangeOauthCode({ ...pending.transaction, code });
|
|
1626
|
+
clearPendingOauthTransaction();
|
|
1627
|
+
onProgress?.({ type: "token_exchange_completed" });
|
|
1628
|
+
return tokens;
|
|
1629
|
+
}
|
|
1457
1630
|
function runOauthFlowForEntryPoint({
|
|
1458
1631
|
options,
|
|
1459
1632
|
entryPoint,
|
|
@@ -1989,12 +2162,19 @@ async function saveClientCredentials({
|
|
|
1989
2162
|
function emitAccountAuthSuccess({
|
|
1990
2163
|
sdk,
|
|
1991
2164
|
profile,
|
|
1992
|
-
clientId
|
|
2165
|
+
clientId,
|
|
2166
|
+
isNonInteractive,
|
|
2167
|
+
isHeadless
|
|
1993
2168
|
}) {
|
|
1994
2169
|
sdk.context.eventEmission.emit(
|
|
1995
2170
|
"platform.sdk.ApplicationLifecycleEvent",
|
|
1996
2171
|
zapierSdk.buildApplicationLifecycleEvent(
|
|
1997
|
-
{
|
|
2172
|
+
{
|
|
2173
|
+
lifecycle_event_type: "login_success",
|
|
2174
|
+
used_non_interactive_mode: isNonInteractive,
|
|
2175
|
+
is_headless: isHeadless,
|
|
2176
|
+
process_argv: sanitizeCliArguments(process.argv.slice(2))
|
|
2177
|
+
},
|
|
1998
2178
|
{
|
|
1999
2179
|
customuser_id: profile.user_id,
|
|
2000
2180
|
account_id: profile.roles[0]?.account_id ?? null,
|
|
@@ -2005,11 +2185,18 @@ function emitAccountAuthSuccess({
|
|
|
2005
2185
|
);
|
|
2006
2186
|
}
|
|
2007
2187
|
function emitSignupSuccess({
|
|
2008
|
-
sdk
|
|
2188
|
+
sdk,
|
|
2189
|
+
isNonInteractive,
|
|
2190
|
+
isHeadless
|
|
2009
2191
|
}) {
|
|
2010
2192
|
sdk.context.eventEmission.emit(
|
|
2011
2193
|
"platform.sdk.ApplicationLifecycleEvent",
|
|
2012
|
-
zapierSdk.buildApplicationLifecycleEvent({
|
|
2194
|
+
zapierSdk.buildApplicationLifecycleEvent({
|
|
2195
|
+
lifecycle_event_type: "signup_success",
|
|
2196
|
+
used_non_interactive_mode: isNonInteractive,
|
|
2197
|
+
is_headless: isHeadless,
|
|
2198
|
+
process_argv: sanitizeCliArguments(process.argv.slice(2))
|
|
2199
|
+
})
|
|
2013
2200
|
);
|
|
2014
2201
|
}
|
|
2015
2202
|
async function runOauthWithRedaction(runOauth) {
|
|
@@ -2040,7 +2227,11 @@ async function runOauthForEntryPoint({
|
|
|
2040
2227
|
recoveryMessage: headless ? HEADLESS_SIGNUP_RECOVERY_MESSAGE : SIGNUP_RECOVERY_MESSAGE,
|
|
2041
2228
|
onProgress: (event) => {
|
|
2042
2229
|
if (event.type === "callback_accepted") {
|
|
2043
|
-
emitSignupSuccess({
|
|
2230
|
+
emitSignupSuccess({
|
|
2231
|
+
sdk,
|
|
2232
|
+
isNonInteractive: false,
|
|
2233
|
+
isHeadless: headless === true
|
|
2234
|
+
});
|
|
2044
2235
|
}
|
|
2045
2236
|
}
|
|
2046
2237
|
})
|
|
@@ -2057,11 +2248,124 @@ async function runOauthForEntryPoint({
|
|
|
2057
2248
|
})
|
|
2058
2249
|
);
|
|
2059
2250
|
}
|
|
2251
|
+
async function provisionAccountCredentials({
|
|
2252
|
+
sdk,
|
|
2253
|
+
entryPoint,
|
|
2254
|
+
accessToken,
|
|
2255
|
+
credentialsBaseUrl,
|
|
2256
|
+
credentialName,
|
|
2257
|
+
interactive,
|
|
2258
|
+
useApprovals,
|
|
2259
|
+
isNonInteractive,
|
|
2260
|
+
isHeadless
|
|
2261
|
+
}) {
|
|
2262
|
+
const scopedApi = zapierSdk.getOrCreateApiClient({
|
|
2263
|
+
credentials: accessToken,
|
|
2264
|
+
baseUrl: credentialsBaseUrl,
|
|
2265
|
+
callerPackage: sdk.context.options?.callerPackage
|
|
2266
|
+
});
|
|
2267
|
+
const profile = await getProfile(scopedApi);
|
|
2268
|
+
process.stderr.write(`${getProfileMessage(entryPoint, profile.email)}
|
|
2269
|
+
`);
|
|
2270
|
+
process.stderr.write(
|
|
2271
|
+
"\nGenerating credentials so this machine can make authenticated requests on your behalf.\n"
|
|
2272
|
+
);
|
|
2273
|
+
const resolvedCredentialName = credentialName ?? await resolveCredentialName({
|
|
2274
|
+
email: profile.email,
|
|
2275
|
+
interactive,
|
|
2276
|
+
baseUrl: credentialsBaseUrl,
|
|
2277
|
+
entryPoint
|
|
2278
|
+
});
|
|
2279
|
+
const { clientId } = await saveClientCredentials({
|
|
2280
|
+
api: scopedApi,
|
|
2281
|
+
name: resolvedCredentialName,
|
|
2282
|
+
credentialsBaseUrl,
|
|
2283
|
+
useApprovals,
|
|
2284
|
+
cleanupLogPrefix: entryPoint
|
|
2285
|
+
});
|
|
2286
|
+
process.stderr.write(
|
|
2287
|
+
`\u2705 Credentials "${resolvedCredentialName}" created and set as default. You are ready to use the Zapier SDK.
|
|
2288
|
+
`
|
|
2289
|
+
);
|
|
2290
|
+
if (useApprovals) {
|
|
2291
|
+
process.stderr.write("\u{1F510} Approvals are enabled for these credentials.\n");
|
|
2292
|
+
}
|
|
2293
|
+
emitAccountAuthSuccess({
|
|
2294
|
+
sdk,
|
|
2295
|
+
profile,
|
|
2296
|
+
clientId,
|
|
2297
|
+
isNonInteractive,
|
|
2298
|
+
isHeadless
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2060
2301
|
async function runAccountAuth({
|
|
2061
2302
|
sdk,
|
|
2062
2303
|
options,
|
|
2063
2304
|
entryPoint
|
|
2064
2305
|
}) {
|
|
2306
|
+
if (options.callbackUrl !== void 0) {
|
|
2307
|
+
const { callbackUrl } = options;
|
|
2308
|
+
const pending = getPendingOauthFlow({ entryPoint });
|
|
2309
|
+
const finishName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
|
|
2310
|
+
if (finishName !== void 0 && finishName !== pending.credentialName) {
|
|
2311
|
+
throw new ZapierCliValidationError(
|
|
2312
|
+
"Cannot change --name while completing a pending OAuth flow. Start a new non-interactive login with the desired --name."
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
if (options.useApprovals === true && !pending.useApprovals) {
|
|
2316
|
+
throw new ZapierCliValidationError(
|
|
2317
|
+
"Cannot add --use-approvals while completing a pending OAuth flow. Start a new non-interactive flow with --use-approvals."
|
|
2318
|
+
);
|
|
2319
|
+
}
|
|
2320
|
+
if (pending.credentialName !== void 0) {
|
|
2321
|
+
const activeCredentials = getActiveCredentials({
|
|
2322
|
+
baseUrl: pending.credentialsBaseUrl
|
|
2323
|
+
});
|
|
2324
|
+
if (activeCredentials?.name !== pending.credentialName && credentialNameExists({
|
|
2325
|
+
name: pending.credentialName,
|
|
2326
|
+
baseUrl: pending.credentialsBaseUrl
|
|
2327
|
+
})) {
|
|
2328
|
+
throw new ZapierCliValidationError(
|
|
2329
|
+
`A credential named "${pending.credentialName}" already exists. Choose a different --name.`
|
|
2330
|
+
);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
if (!await clearExistingAuthState({
|
|
2334
|
+
sdk,
|
|
2335
|
+
baseUrl: pending.credentialsBaseUrl,
|
|
2336
|
+
interactive: false,
|
|
2337
|
+
entryPoint
|
|
2338
|
+
})) {
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
const { accessToken: accessToken2 } = await runOauthWithRedaction(async () => {
|
|
2342
|
+
return resumePendingOauthFlow({
|
|
2343
|
+
callbackUrl,
|
|
2344
|
+
pending,
|
|
2345
|
+
onProgress: (event) => {
|
|
2346
|
+
if (entryPoint === "signup" && event.type === "callback_accepted") {
|
|
2347
|
+
emitSignupSuccess({
|
|
2348
|
+
sdk,
|
|
2349
|
+
isNonInteractive: true,
|
|
2350
|
+
isHeadless: pending.headless
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
});
|
|
2355
|
+
});
|
|
2356
|
+
await provisionAccountCredentials({
|
|
2357
|
+
sdk,
|
|
2358
|
+
entryPoint,
|
|
2359
|
+
accessToken: accessToken2,
|
|
2360
|
+
credentialsBaseUrl: pending.credentialsBaseUrl,
|
|
2361
|
+
credentialName: pending.credentialName,
|
|
2362
|
+
interactive: false,
|
|
2363
|
+
useApprovals: pending.useApprovals,
|
|
2364
|
+
isNonInteractive: true,
|
|
2365
|
+
isHeadless: pending.headless
|
|
2366
|
+
});
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2065
2369
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
2066
2370
|
const interactive = !resolveNonInteractive(options);
|
|
2067
2371
|
const resolvedCredentials = await sdk.context.resolveCredentials();
|
|
@@ -2090,6 +2394,19 @@ async function runAccountAuth({
|
|
|
2090
2394
|
})) {
|
|
2091
2395
|
return;
|
|
2092
2396
|
}
|
|
2397
|
+
const useApprovals = options.useApprovals === true;
|
|
2398
|
+
if (!interactive) {
|
|
2399
|
+
await startPendingOauthFlow({
|
|
2400
|
+
entryPoint,
|
|
2401
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
2402
|
+
pkceCredentials,
|
|
2403
|
+
baseUrl: credentialsBaseUrl,
|
|
2404
|
+
credentialName: providedName,
|
|
2405
|
+
useApprovals,
|
|
2406
|
+
headless
|
|
2407
|
+
});
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2093
2410
|
const { accessToken } = await runOauthForEntryPoint({
|
|
2094
2411
|
sdk,
|
|
2095
2412
|
entryPoint,
|
|
@@ -2099,39 +2416,17 @@ async function runAccountAuth({
|
|
|
2099
2416
|
headless,
|
|
2100
2417
|
interactive
|
|
2101
2418
|
});
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
});
|
|
2107
|
-
const profile = await getProfile(scopedApi);
|
|
2108
|
-
process.stderr.write(`${getProfileMessage(entryPoint, profile.email)}
|
|
2109
|
-
`);
|
|
2110
|
-
process.stderr.write(
|
|
2111
|
-
"\nGenerating credentials so this machine can make authenticated requests on your behalf.\n"
|
|
2112
|
-
);
|
|
2113
|
-
const credentialName = providedName ?? await resolveCredentialName({
|
|
2114
|
-
email: profile.email,
|
|
2115
|
-
interactive,
|
|
2116
|
-
baseUrl: credentialsBaseUrl,
|
|
2117
|
-
entryPoint
|
|
2118
|
-
});
|
|
2119
|
-
const useApprovals = options.useApprovals === true;
|
|
2120
|
-
const { clientId } = await saveClientCredentials({
|
|
2121
|
-
api: scopedApi,
|
|
2122
|
-
name: credentialName,
|
|
2419
|
+
await provisionAccountCredentials({
|
|
2420
|
+
sdk,
|
|
2421
|
+
entryPoint,
|
|
2422
|
+
accessToken,
|
|
2123
2423
|
credentialsBaseUrl,
|
|
2424
|
+
credentialName: providedName,
|
|
2425
|
+
interactive,
|
|
2124
2426
|
useApprovals,
|
|
2125
|
-
|
|
2427
|
+
isNonInteractive: false,
|
|
2428
|
+
isHeadless: headless
|
|
2126
2429
|
});
|
|
2127
|
-
process.stderr.write(
|
|
2128
|
-
`\u2705 Credentials "${credentialName}" created and set as default. You are ready to use the Zapier SDK.
|
|
2129
|
-
`
|
|
2130
|
-
);
|
|
2131
|
-
if (useApprovals) {
|
|
2132
|
-
process.stderr.write("\u{1F510} Approvals are enabled for these credentials.\n");
|
|
2133
|
-
}
|
|
2134
|
-
emitAccountAuthSuccess({ sdk, profile, clientId });
|
|
2135
2430
|
}
|
|
2136
2431
|
var LoginSchema = zod.z.object({
|
|
2137
2432
|
name: zod.z.string().optional().describe(
|
|
@@ -2151,8 +2446,20 @@ var LoginSchema = zod.z.object({
|
|
|
2151
2446
|
}),
|
|
2152
2447
|
headless: zod.z.boolean().optional().describe(
|
|
2153
2448
|
"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."
|
|
2449
|
+
),
|
|
2450
|
+
callbackUrl: zod.z.string().optional().describe(
|
|
2451
|
+
"Resume a pending non-interactive login with the final OAuth callback URL from your browser."
|
|
2154
2452
|
)
|
|
2155
|
-
}).describe("Log in to Zapier to access your account")
|
|
2453
|
+
}).describe("Log in to Zapier to access your account").meta({
|
|
2454
|
+
cliTelemetry: {
|
|
2455
|
+
authFlow: {
|
|
2456
|
+
callbackUrlParam: "callbackUrl",
|
|
2457
|
+
headlessParam: "headless",
|
|
2458
|
+
nonInteractiveParam: "nonInteractive",
|
|
2459
|
+
skipPromptsParam: "skipPrompts"
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2156
2463
|
|
|
2157
2464
|
// src/plugins/login/index.ts
|
|
2158
2465
|
var loginPlugin = zapierSdk.definePlugin(
|
|
@@ -2181,8 +2488,20 @@ var SignupSchema = zod.z.object({
|
|
|
2181
2488
|
}),
|
|
2182
2489
|
headless: zod.z.boolean().optional().describe(
|
|
2183
2490
|
"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."
|
|
2491
|
+
),
|
|
2492
|
+
callbackUrl: zod.z.string().optional().describe(
|
|
2493
|
+
"Resume a pending non-interactive signup with the final OAuth callback URL from your browser."
|
|
2184
2494
|
)
|
|
2185
|
-
}).describe("Set up Zapier account access and SDK credentials")
|
|
2495
|
+
}).describe("Set up Zapier account access and SDK credentials").meta({
|
|
2496
|
+
cliTelemetry: {
|
|
2497
|
+
authFlow: {
|
|
2498
|
+
callbackUrlParam: "callbackUrl",
|
|
2499
|
+
headlessParam: "headless",
|
|
2500
|
+
nonInteractiveParam: "nonInteractive",
|
|
2501
|
+
skipPromptsParam: "skipPrompts"
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
});
|
|
2186
2505
|
|
|
2187
2506
|
// src/plugins/signup/index.ts
|
|
2188
2507
|
var signupPlugin = zapierSdk.definePlugin(
|
|
@@ -4480,7 +4799,7 @@ var ExecCliProperty = zod.z.string().optional().describe(
|
|
|
4480
4799
|
var ExecShellCliProperty = zod.z.string().optional().describe(
|
|
4481
4800
|
"Run a shell command per message. Message JSON is piped to the subprocess on stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Interpreted by the platform's default shell (sh on POSIX, cmd.exe on Windows). Mutually exclusive with --exec and --json."
|
|
4482
4801
|
);
|
|
4483
|
-
zapierSdk.definePlugin(
|
|
4802
|
+
var drainTriggerInboxCliPlugin = zapierSdk.definePlugin(
|
|
4484
4803
|
(sdk) => {
|
|
4485
4804
|
const original = sdk.drainTriggerInbox;
|
|
4486
4805
|
const existingMeta = sdk.context.meta.drainTriggerInbox;
|
|
@@ -4610,7 +4929,7 @@ var ExecCliProperty2 = zod.z.string().optional().describe(
|
|
|
4610
4929
|
var ExecShellCliProperty2 = zod.z.string().optional().describe(
|
|
4611
4930
|
"Run a shell command per message. Message JSON is piped to the subprocess on stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Interpreted by the platform's default shell (sh on POSIX, cmd.exe on Windows). Mutually exclusive with --exec and --json."
|
|
4612
4931
|
);
|
|
4613
|
-
zapierSdk.definePlugin(
|
|
4932
|
+
var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
|
|
4614
4933
|
(sdk) => {
|
|
4615
4934
|
const original = sdk.watchTriggerInbox;
|
|
4616
4935
|
const existingMeta = sdk.context.meta.watchTriggerInbox;
|
|
@@ -4740,7 +5059,7 @@ function collectDeprecationNoticeAndForward(event, onEvent) {
|
|
|
4740
5059
|
// package.json with { type: 'json' }
|
|
4741
5060
|
var package_default = {
|
|
4742
5061
|
name: "@zapier/zapier-sdk-cli",
|
|
4743
|
-
version: "0.
|
|
5062
|
+
version: "0.64.0"};
|
|
4744
5063
|
|
|
4745
5064
|
// src/sdk.ts
|
|
4746
5065
|
zapierSdk.injectCliLogin(login_exports);
|
|
@@ -4757,7 +5076,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4757
5076
|
// box is additive: the SDK's own inline warn still fires, so the notice
|
|
4758
5077
|
// cannot be hidden by any rendering path.
|
|
4759
5078
|
onEvent: (event) => collectDeprecationNoticeAndForward(event, sdkOptions.onEvent)
|
|
4760
|
-
}).use(extensionsContextPlugin).use(generateAppTypesPlugin).use(buildManifestPlugin).use(bundleCodePlugin).use(getLoginConfigPathPlugin).use(addAppsPlugin).use(feedbackPlugin).use(curlPlugin).use(initPlugin).use(mcpPlugin).use(loginPlugin).use(signupPlugin).use(logoutPlugin).use(cliOverridesPlugin, { override: true });
|
|
5079
|
+
}).use(extensionsContextPlugin).use(generateAppTypesPlugin).use(buildManifestPlugin).use(bundleCodePlugin).use(getLoginConfigPathPlugin).use(addAppsPlugin).use(feedbackPlugin).use(curlPlugin).use(initPlugin).use(drainTriggerInboxCliPlugin, { override: true }).use(watchTriggerInboxCliPlugin, { override: true }).use(mcpPlugin).use(loginPlugin).use(signupPlugin).use(logoutPlugin).use(cliOverridesPlugin, { override: true });
|
|
4761
5080
|
const sdk = zapierSdk.createSdk(
|
|
4762
5081
|
zapierSdk.defineLegacyMerge({
|
|
4763
5082
|
namespace: "zapier",
|
|
@@ -4780,7 +5099,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4780
5099
|
|
|
4781
5100
|
// package.json
|
|
4782
5101
|
var package_default2 = {
|
|
4783
|
-
version: "0.
|
|
5102
|
+
version: "0.64.0"};
|
|
4784
5103
|
|
|
4785
5104
|
// src/telemetry/builders.ts
|
|
4786
5105
|
function createCliBaseEvent(context = {}) {
|
|
@@ -4835,7 +5154,9 @@ function buildCliCommandExecutedEvent({
|
|
|
4835
5154
|
files_created_count: data.files_created_count ?? null,
|
|
4836
5155
|
files_processed_size_bytes: data.files_processed_size_bytes ?? null,
|
|
4837
5156
|
cpu_time_ms: data.cpu_time_ms ?? null,
|
|
4838
|
-
subprocess_count: data.subprocess_count ?? null
|
|
5157
|
+
subprocess_count: data.subprocess_count ?? null,
|
|
5158
|
+
used_non_interactive_mode: data.used_non_interactive_mode ?? null,
|
|
5159
|
+
is_headless: data.is_headless ?? null
|
|
4839
5160
|
};
|
|
4840
5161
|
}
|
|
4841
5162
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZapierSdkOptions, BaseEvent } from '@zapier/zapier-sdk';
|
|
2
|
-
import { E as Extension, Z as ZapierSdkCli } from './extensions-
|
|
2
|
+
import { E as Extension, Z as ZapierSdkCli } from './extensions-N27h0wrp.mjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
interface ZapierCliSdkOptions extends ZapierSdkOptions {
|
|
@@ -54,6 +54,8 @@ interface CliCommandExecutedEvent extends BaseEvent {
|
|
|
54
54
|
peak_memory_usage_bytes?: number | null;
|
|
55
55
|
cpu_time_ms?: number | null;
|
|
56
56
|
subprocess_count?: number | null;
|
|
57
|
+
used_non_interactive_mode?: boolean | null;
|
|
58
|
+
is_headless?: boolean | null;
|
|
57
59
|
stdin_is_tty?: boolean | null;
|
|
58
60
|
stdout_is_tty?: boolean | null;
|
|
59
61
|
agent?: string | null;
|
|
@@ -96,6 +98,8 @@ interface CliCommandExecutedEventData {
|
|
|
96
98
|
peak_memory_usage_bytes?: number | null;
|
|
97
99
|
cpu_time_ms?: number | null;
|
|
98
100
|
subprocess_count?: number | null;
|
|
101
|
+
used_non_interactive_mode?: boolean | null;
|
|
102
|
+
is_headless?: boolean | null;
|
|
99
103
|
package_manager?: string | null;
|
|
100
104
|
}
|
|
101
105
|
declare function buildCliCommandExecutedEvent({ data, context, cliVersion, }: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZapierSdkOptions, BaseEvent } from '@zapier/zapier-sdk';
|
|
2
|
-
import { E as Extension, Z as ZapierSdkCli } from './extensions-
|
|
2
|
+
import { E as Extension, Z as ZapierSdkCli } from './extensions-N27h0wrp.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
interface ZapierCliSdkOptions extends ZapierSdkOptions {
|
|
@@ -54,6 +54,8 @@ interface CliCommandExecutedEvent extends BaseEvent {
|
|
|
54
54
|
peak_memory_usage_bytes?: number | null;
|
|
55
55
|
cpu_time_ms?: number | null;
|
|
56
56
|
subprocess_count?: number | null;
|
|
57
|
+
used_non_interactive_mode?: boolean | null;
|
|
58
|
+
is_headless?: boolean | null;
|
|
57
59
|
stdin_is_tty?: boolean | null;
|
|
58
60
|
stdout_is_tty?: boolean | null;
|
|
59
61
|
agent?: string | null;
|
|
@@ -96,6 +98,8 @@ interface CliCommandExecutedEventData {
|
|
|
96
98
|
peak_memory_usage_bytes?: number | null;
|
|
97
99
|
cpu_time_ms?: number | null;
|
|
98
100
|
subprocess_count?: number | null;
|
|
101
|
+
used_non_interactive_mode?: boolean | null;
|
|
102
|
+
is_headless?: boolean | null;
|
|
99
103
|
package_manager?: string | null;
|
|
100
104
|
}
|
|
101
105
|
declare function buildCliCommandExecutedEvent({ data, context, cliVersion, }: {
|