@zapier/zapier-sdk-cli 0.52.1 → 0.52.3
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 +14 -0
- package/README.md +6 -5
- package/dist/cli.cjs +19 -13
- package/dist/cli.mjs +19 -13
- package/dist/experimental.cjs +18 -12
- package/dist/experimental.mjs +18 -12
- package/dist/index.cjs +19 -13
- package/dist/index.mjs +19 -13
- package/dist/package.json +1 -1
- package/dist/src/plugins/login/index.d.ts +1 -0
- package/dist/src/plugins/login/index.js +15 -12
- package/dist/src/plugins/login/schemas.d.ts +1 -0
- package/dist/src/plugins/login/schemas.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1224,6 +1224,9 @@ var LoginSchema = z.object({
|
|
|
1224
1224
|
timeout: z.string().optional().describe("Login timeout in seconds (default: 300)"),
|
|
1225
1225
|
useApprovals: z.boolean().optional().describe(
|
|
1226
1226
|
"Require approvals for actions performed with these credentials"
|
|
1227
|
+
),
|
|
1228
|
+
skipPrompts: z.boolean().optional().describe(
|
|
1229
|
+
"Skip interactive prompts. Uses defaults where possible; errors instead of prompting when input is required. Useful in CI, piped output, or environments where TTY detection is unreliable."
|
|
1227
1230
|
)
|
|
1228
1231
|
}).describe("Log in to Zapier to access your account");
|
|
1229
1232
|
|
|
@@ -1239,8 +1242,8 @@ function toPkceCredentials(credentials) {
|
|
|
1239
1242
|
}
|
|
1240
1243
|
return void 0;
|
|
1241
1244
|
}
|
|
1242
|
-
async function confirmRevokeAndRelogin(activeCredentials) {
|
|
1243
|
-
if (
|
|
1245
|
+
async function confirmRevokeAndRelogin(activeCredentials, skipPrompts) {
|
|
1246
|
+
if (skipPrompts) {
|
|
1244
1247
|
throw new ZapierCliValidationError(
|
|
1245
1248
|
`Already logged in as "${activeCredentials.name}". Run \`logout\` first or use an interactive terminal to re-authenticate.`
|
|
1246
1249
|
);
|
|
@@ -1261,8 +1264,8 @@ Log out and log in again?`,
|
|
|
1261
1264
|
}
|
|
1262
1265
|
return true;
|
|
1263
1266
|
}
|
|
1264
|
-
async function confirmJwtMigration() {
|
|
1265
|
-
if (
|
|
1267
|
+
async function confirmJwtMigration(skipPrompts) {
|
|
1268
|
+
if (skipPrompts) {
|
|
1266
1269
|
throw new ZapierCliValidationError(
|
|
1267
1270
|
"Legacy JWT login detected. Run `logout` first or use an interactive terminal to migrate to client credentials."
|
|
1268
1271
|
);
|
|
@@ -1281,8 +1284,8 @@ async function confirmJwtMigration() {
|
|
|
1281
1284
|
}
|
|
1282
1285
|
return true;
|
|
1283
1286
|
}
|
|
1284
|
-
async function confirmLocalLoginReset() {
|
|
1285
|
-
if (
|
|
1287
|
+
async function confirmLocalLoginReset(skipPrompts) {
|
|
1288
|
+
if (skipPrompts) {
|
|
1286
1289
|
throw new ZapierCliValidationError(
|
|
1287
1290
|
"Login cleanup failed and cannot be reset without confirmation. Re-run with an interactive terminal."
|
|
1288
1291
|
);
|
|
@@ -1308,9 +1311,9 @@ function parseTimeoutSeconds(timeout) {
|
|
|
1308
1311
|
}
|
|
1309
1312
|
return timeoutSeconds;
|
|
1310
1313
|
}
|
|
1311
|
-
async function promptCredentialsName(email, baseUrl) {
|
|
1314
|
+
async function promptCredentialsName(email, skipPrompts, baseUrl) {
|
|
1312
1315
|
const fallback = `${email}@${hostname()}`;
|
|
1313
|
-
if (
|
|
1316
|
+
if (skipPrompts) {
|
|
1314
1317
|
if (credentialsNameExists({ name: fallback, baseUrl })) {
|
|
1315
1318
|
throw new ZapierCliValidationError(
|
|
1316
1319
|
`Credentials named "${fallback}" already exist. Run \`logout\` first or use an interactive terminal to choose a different name.`
|
|
@@ -1372,6 +1375,7 @@ var loginPlugin = definePlugin(
|
|
|
1372
1375
|
supportsJsonOutput: false,
|
|
1373
1376
|
handler: async ({ sdk: sdk2, options }) => {
|
|
1374
1377
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
1378
|
+
const skipPrompts = options.skipPrompts === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
1375
1379
|
const resolvedCredentials = await sdk2.context.resolveCredentials();
|
|
1376
1380
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
1377
1381
|
const credentialsBaseUrl = await resolveCredentialsBaseUrl({
|
|
@@ -1382,21 +1386,22 @@ var loginPlugin = definePlugin(
|
|
|
1382
1386
|
baseUrl: credentialsBaseUrl
|
|
1383
1387
|
});
|
|
1384
1388
|
if (activeCredentials) {
|
|
1385
|
-
if (!await confirmRevokeAndRelogin(activeCredentials))
|
|
1389
|
+
if (!await confirmRevokeAndRelogin(activeCredentials, skipPrompts))
|
|
1390
|
+
return;
|
|
1386
1391
|
try {
|
|
1387
1392
|
await revokeCredentials({
|
|
1388
1393
|
api: sdk2.context.api,
|
|
1389
1394
|
credentials: activeCredentials
|
|
1390
1395
|
});
|
|
1391
1396
|
} catch {
|
|
1392
|
-
if (!await confirmLocalLoginReset()) return;
|
|
1397
|
+
if (!await confirmLocalLoginReset(skipPrompts)) return;
|
|
1393
1398
|
await deleteStoredClientCredentials({
|
|
1394
1399
|
name: activeCredentials.name,
|
|
1395
1400
|
baseUrl: activeCredentials.baseUrl
|
|
1396
1401
|
});
|
|
1397
1402
|
}
|
|
1398
1403
|
} else if (hasLegacyJwtConfig()) {
|
|
1399
|
-
if (!await confirmJwtMigration()) return;
|
|
1404
|
+
if (!await confirmJwtMigration(skipPrompts)) return;
|
|
1400
1405
|
}
|
|
1401
1406
|
const { accessToken } = await runOauthFlow({
|
|
1402
1407
|
timeoutMs: timeoutSeconds * 1e3,
|
|
@@ -1414,6 +1419,7 @@ var loginPlugin = definePlugin(
|
|
|
1414
1419
|
);
|
|
1415
1420
|
const credentialName = await promptCredentialsName(
|
|
1416
1421
|
profile.email,
|
|
1422
|
+
skipPrompts,
|
|
1417
1423
|
credentialsBaseUrl
|
|
1418
1424
|
);
|
|
1419
1425
|
const useApprovals = options.useApprovals === true;
|
|
@@ -3973,7 +3979,7 @@ definePlugin(
|
|
|
3973
3979
|
// package.json with { type: 'json' }
|
|
3974
3980
|
var package_default = {
|
|
3975
3981
|
name: "@zapier/zapier-sdk-cli",
|
|
3976
|
-
version: "0.52.
|
|
3982
|
+
version: "0.52.3"};
|
|
3977
3983
|
|
|
3978
3984
|
// src/sdk.ts
|
|
3979
3985
|
injectCliLogin(login_exports);
|
|
@@ -4001,7 +4007,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4001
4007
|
|
|
4002
4008
|
// package.json
|
|
4003
4009
|
var package_default2 = {
|
|
4004
|
-
version: "0.52.
|
|
4010
|
+
version: "0.52.3"};
|
|
4005
4011
|
|
|
4006
4012
|
// src/telemetry/builders.ts
|
|
4007
4013
|
function createCliBaseEvent(context = {}) {
|
package/dist/package.json
CHANGED
|
@@ -22,8 +22,8 @@ function toPkceCredentials(credentials) {
|
|
|
22
22
|
}
|
|
23
23
|
return undefined;
|
|
24
24
|
}
|
|
25
|
-
async function confirmRevokeAndRelogin(activeCredentials) {
|
|
26
|
-
if (
|
|
25
|
+
async function confirmRevokeAndRelogin(activeCredentials, skipPrompts) {
|
|
26
|
+
if (skipPrompts) {
|
|
27
27
|
throw new ZapierCliValidationError(`Already logged in as "${activeCredentials.name}". Run \`logout\` first or use an interactive terminal to re-authenticate.`);
|
|
28
28
|
}
|
|
29
29
|
const { confirmed } = await inquirer.prompt([
|
|
@@ -42,8 +42,8 @@ async function confirmRevokeAndRelogin(activeCredentials) {
|
|
|
42
42
|
}
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
|
-
async function confirmJwtMigration() {
|
|
46
|
-
if (
|
|
45
|
+
async function confirmJwtMigration(skipPrompts) {
|
|
46
|
+
if (skipPrompts) {
|
|
47
47
|
throw new ZapierCliValidationError("Legacy JWT login detected. Run `logout` first or use an interactive terminal to migrate to client credentials.");
|
|
48
48
|
}
|
|
49
49
|
const { confirmed } = await inquirer.prompt([
|
|
@@ -63,8 +63,8 @@ async function confirmJwtMigration() {
|
|
|
63
63
|
}
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
|
-
async function confirmLocalLoginReset() {
|
|
67
|
-
if (
|
|
66
|
+
async function confirmLocalLoginReset(skipPrompts) {
|
|
67
|
+
if (skipPrompts) {
|
|
68
68
|
throw new ZapierCliValidationError("Login cleanup failed and cannot be reset without confirmation. Re-run with an interactive terminal.");
|
|
69
69
|
}
|
|
70
70
|
const { confirmed } = await inquirer.prompt([
|
|
@@ -88,9 +88,9 @@ function parseTimeoutSeconds(timeout) {
|
|
|
88
88
|
}
|
|
89
89
|
return timeoutSeconds;
|
|
90
90
|
}
|
|
91
|
-
async function promptCredentialsName(email, baseUrl) {
|
|
91
|
+
async function promptCredentialsName(email, skipPrompts, baseUrl) {
|
|
92
92
|
const fallback = `${email}@${hostname()}`;
|
|
93
|
-
if (
|
|
93
|
+
if (skipPrompts) {
|
|
94
94
|
if (credentialsNameExists({ name: fallback, baseUrl })) {
|
|
95
95
|
throw new ZapierCliValidationError(`Credentials named "${fallback}" already exist. Run \`logout\` first or use an interactive terminal to choose a different name.`);
|
|
96
96
|
}
|
|
@@ -143,6 +143,9 @@ export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
|
143
143
|
supportsJsonOutput: false,
|
|
144
144
|
handler: async ({ sdk, options }) => {
|
|
145
145
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
146
|
+
const skipPrompts = options.skipPrompts === true ||
|
|
147
|
+
!process.stdin.isTTY ||
|
|
148
|
+
!process.stdout.isTTY;
|
|
146
149
|
const resolvedCredentials = await sdk.context.resolveCredentials();
|
|
147
150
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
148
151
|
const credentialsBaseUrl = await resolveCredentialsBaseUrl({
|
|
@@ -153,7 +156,7 @@ export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
|
153
156
|
baseUrl: credentialsBaseUrl,
|
|
154
157
|
});
|
|
155
158
|
if (activeCredentials) {
|
|
156
|
-
if (!(await confirmRevokeAndRelogin(activeCredentials)))
|
|
159
|
+
if (!(await confirmRevokeAndRelogin(activeCredentials, skipPrompts)))
|
|
157
160
|
return;
|
|
158
161
|
try {
|
|
159
162
|
await revokeCredentials({
|
|
@@ -162,7 +165,7 @@ export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
|
162
165
|
});
|
|
163
166
|
}
|
|
164
167
|
catch {
|
|
165
|
-
if (!(await confirmLocalLoginReset()))
|
|
168
|
+
if (!(await confirmLocalLoginReset(skipPrompts)))
|
|
166
169
|
return;
|
|
167
170
|
await deleteStoredClientCredentials({
|
|
168
171
|
name: activeCredentials.name,
|
|
@@ -171,7 +174,7 @@ export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
else if (hasLegacyJwtConfig()) {
|
|
174
|
-
if (!(await confirmJwtMigration()))
|
|
177
|
+
if (!(await confirmJwtMigration(skipPrompts)))
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
177
180
|
const { accessToken } = await runOauthFlow({
|
|
@@ -186,7 +189,7 @@ export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
|
186
189
|
const profile = await getProfile(scopedApi);
|
|
187
190
|
console.log(`👤 Logged in as ${profile.email}`);
|
|
188
191
|
console.log("\nGenerating credentials so this machine can make authenticated requests on your behalf.");
|
|
189
|
-
const credentialName = await promptCredentialsName(profile.email, credentialsBaseUrl);
|
|
192
|
+
const credentialName = await promptCredentialsName(profile.email, skipPrompts, credentialsBaseUrl);
|
|
190
193
|
const useApprovals = options.useApprovals === true;
|
|
191
194
|
await setupClientCredentials({
|
|
192
195
|
api: scopedApi,
|
|
@@ -2,5 +2,6 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const LoginSchema: z.ZodObject<{
|
|
3
3
|
timeout: z.ZodOptional<z.ZodString>;
|
|
4
4
|
useApprovals: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
skipPrompts: z.ZodOptional<z.ZodBoolean>;
|
|
5
6
|
}, z.core.$strip>;
|
|
6
7
|
export type LoginOptions = z.infer<typeof LoginSchema>;
|
|
@@ -10,5 +10,9 @@ export const LoginSchema = z
|
|
|
10
10
|
.boolean()
|
|
11
11
|
.optional()
|
|
12
12
|
.describe("Require approvals for actions performed with these credentials"),
|
|
13
|
+
skipPrompts: z
|
|
14
|
+
.boolean()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Skip interactive prompts. Uses defaults where possible; errors instead of prompting when input is required. Useful in CI, piped output, or environments where TTY detection is unreliable."),
|
|
13
17
|
})
|
|
14
18
|
.describe("Log in to Zapier to access your account");
|