@assinafy/cli 2.4.1 → 2.5.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/dist/cli.cjs CHANGED
@@ -9038,10 +9038,10 @@ var require_abort = __commonJS({
9038
9038
  "use strict";
9039
9039
  module2.exports = abort;
9040
9040
  function abort(state) {
9041
- Object.keys(state.jobs).forEach(clean2.bind(state));
9041
+ Object.keys(state.jobs).forEach(clean.bind(state));
9042
9042
  state.jobs = {};
9043
9043
  }
9044
- function clean2(key) {
9044
+ function clean(key) {
9045
9045
  if (typeof this.jobs[key] == "function") {
9046
9046
  this.jobs[key]();
9047
9047
  }
@@ -21605,6 +21605,12 @@ var AssignmentResource = class extends BaseResource {
21605
21605
  };
21606
21606
 
21607
21607
  // src/api/resources/authentication.ts
21608
+ function requireReauth(payload) {
21609
+ if (!payload?.password && !payload?.code) {
21610
+ throw new ValidationError("password or code is required");
21611
+ }
21612
+ return payload;
21613
+ }
21608
21614
  var AuthenticationResource = class extends BaseResource {
21609
21615
  /** `POST /login` — exchange email + password for a JWT access token. */
21610
21616
  async login(email, password2) {
@@ -21615,6 +21621,70 @@ var AuthenticationResource = class extends BaseResource {
21615
21621
  () => this.http.post("/login", { email, password: password2 }, publicRequestConfig())
21616
21622
  );
21617
21623
  }
21624
+ /**
21625
+ * `POST /authentication/mfa/verify` — exchange the login `mfa_token` and an
21626
+ * authenticator or recovery code for an access token. The challenge is
21627
+ * single-use and expires 5 minutes after login.
21628
+ */
21629
+ async verifyMfa(payload) {
21630
+ if (!payload?.mfa_token) throw new ValidationError("mfa_token is required");
21631
+ if (!payload.code?.trim()) throw new ValidationError("code is required");
21632
+ return this.call(
21633
+ "Two-factor verification failed",
21634
+ () => this.http.post(
21635
+ "/authentication/mfa/verify",
21636
+ { mfa_token: payload.mfa_token, code: payload.code.trim() },
21637
+ publicRequestConfig()
21638
+ )
21639
+ );
21640
+ }
21641
+ /** `GET /users/self/mfa` — enrolled two-factor methods and remaining recovery codes. */
21642
+ async listMfaMethods() {
21643
+ return this.call("Failed to list two-factor methods", () => this.http.get("/users/self/mfa"));
21644
+ }
21645
+ /**
21646
+ * `POST /users/self/mfa/totp` — start authenticator enrollment. The secret
21647
+ * and provisioning URI are returned only once; two-factor stays inactive
21648
+ * until {@link confirmTotpEnrollment}.
21649
+ */
21650
+ async startTotpEnrollment(label) {
21651
+ return this.call(
21652
+ "Failed to start authenticator enrollment",
21653
+ () => this.http.post("/users/self/mfa/totp", label ? { label } : {})
21654
+ );
21655
+ }
21656
+ /**
21657
+ * `PUT /users/self/mfa/totp/confirm` — activate the method with a live code
21658
+ * and receive one-time recovery codes. Replacing a confirmed method also
21659
+ * requires `password` or `reauth_code`.
21660
+ */
21661
+ async confirmTotpEnrollment(payload) {
21662
+ if (!payload?.id) throw new ValidationError("id is required");
21663
+ if (!payload.code?.trim()) throw new ValidationError("code is required");
21664
+ return this.call(
21665
+ "Failed to confirm authenticator enrollment",
21666
+ () => this.http.put("/users/self/mfa/totp/confirm", payload)
21667
+ );
21668
+ }
21669
+ /** `POST /users/self/mfa/recovery-codes` — issue ten new recovery codes, invalidating the old set. */
21670
+ async regenerateRecoveryCodes(payload) {
21671
+ return this.call(
21672
+ "Failed to regenerate recovery codes",
21673
+ () => this.http.post("/users/self/mfa/recovery-codes", requireReauth(payload))
21674
+ );
21675
+ }
21676
+ /**
21677
+ * `DELETE /users/self/mfa/{methodId}` — remove a method. Removing the last
21678
+ * one also discards the recovery codes.
21679
+ */
21680
+ async removeMfaMethod(methodId, payload) {
21681
+ const id = this.requireId(methodId, "Method ID");
21682
+ const data = requireReauth(payload);
21683
+ return this.call(
21684
+ "Failed to remove two-factor method",
21685
+ () => this.http.delete(`/users/self/mfa/${id}`, { data })
21686
+ );
21687
+ }
21618
21688
  /** `POST /authentication/social-login` — exchange a provider token for an Assinafy JWT. */
21619
21689
  async socialLogin(payload) {
21620
21690
  if (payload.provider !== "google") throw new ValidationError("provider must be google");
@@ -22220,7 +22290,11 @@ var FieldsResource = class extends BaseResource {
22220
22290
  }
22221
22291
  };
22222
22292
  function validationConfig(signerAccessCode) {
22223
- return signerAccessCode ? signerAccessConfig(signerAccessCode) : void 0;
22293
+ if (signerAccessCode === void 0) return void 0;
22294
+ if (typeof signerAccessCode !== "string" || !signerAccessCode.trim()) {
22295
+ throw new ValidationError("signerAccessCode is required when supplied");
22296
+ }
22297
+ return signerAccessConfig(signerAccessCode);
22224
22298
  }
22225
22299
 
22226
22300
  // src/api/resources/oauth.ts
@@ -22328,6 +22402,9 @@ var OAuthResource = class extends BaseResource {
22328
22402
  if (callback.searchParams.get("iss") !== request.issuer) {
22329
22403
  throw new ValidationError("OAuth issuer mismatch");
22330
22404
  }
22405
+ if (callback.searchParams.has("code") === callback.searchParams.has("error")) {
22406
+ throw new ValidationError("OAuth callback must contain exactly one of code or error");
22407
+ }
22331
22408
  if (callback.searchParams.has("error")) {
22332
22409
  const error = callback.searchParams.get("error");
22333
22410
  const oauthError = error.length > 0 && error.length <= 64 && !/[^a-z_]/.test(error) ? error : "unknown_error";
@@ -22989,10 +23066,8 @@ var DEFAULT_EVENTS = [
22989
23066
  "signer_rejected_document",
22990
23067
  "document_processing_failed"
22991
23068
  ];
22992
- var WebhookResource = class extends BaseResource {
22993
- /** Register (or replace) the webhook subscription for the workspace. */
22994
- async register(payload, accountId) {
22995
- if (!payload.url) throw new ValidationError("Webhook URL is required");
23069
+ function validateWebhookFields(payload) {
23070
+ if (payload.url !== void 0) {
22996
23071
  let webhookUrl;
22997
23072
  try {
22998
23073
  webhookUrl = new URL(payload.url);
@@ -23002,13 +23077,29 @@ var WebhookResource = class extends BaseResource {
23002
23077
  if (webhookUrl.protocol !== "http:" && webhookUrl.protocol !== "https:") {
23003
23078
  throw new ValidationError("Webhook URL must be a valid HTTP(S) URL");
23004
23079
  }
23005
- requireEmail(payload.email);
23006
- if (payload.events !== void 0 && (!Array.isArray(payload.events) || payload.events.some((event) => typeof event !== "string" || !event))) {
23007
- throw new ValidationError("Webhook events must contain non-empty strings");
23008
- }
23009
- if (payload.is_active !== void 0 && typeof payload.is_active !== "boolean") {
23010
- throw new ValidationError("Webhook is_active must be a boolean");
23080
+ }
23081
+ if (payload.email !== void 0) requireEmail(payload.email);
23082
+ if (payload.events !== void 0 && (!Array.isArray(payload.events) || payload.events.some((event) => typeof event !== "string" || !event))) {
23083
+ throw new ValidationError("Webhook events must contain non-empty strings");
23084
+ }
23085
+ if (payload.name !== void 0 && typeof payload.name !== "string") {
23086
+ throw new ValidationError("Webhook name must be a string");
23087
+ }
23088
+ for (const key of ["is_active", "signing_enabled"]) {
23089
+ if (payload[key] !== void 0 && typeof payload[key] !== "boolean") {
23090
+ throw new ValidationError(`Webhook ${key} must be a boolean`);
23011
23091
  }
23092
+ }
23093
+ }
23094
+ var WebhookResource = class extends BaseResource {
23095
+ /**
23096
+ * `PUT /accounts/{accountId}/webhooks/subscriptions` — create or replace the
23097
+ * account's oldest webhook endpoint. Use the endpoint methods for accounts
23098
+ * with several endpoints or for signed deliveries.
23099
+ */
23100
+ async register(payload, accountId) {
23101
+ if (!payload.url) throw new ValidationError("Webhook URL is required");
23102
+ validateWebhookFields({ ...payload, email: payload.email ?? "" });
23012
23103
  const id = this.accountId(accountId);
23013
23104
  const body = {
23014
23105
  url: payload.url,
@@ -23024,7 +23115,7 @@ var WebhookResource = class extends BaseResource {
23024
23115
  () => this.http.put(`/accounts/${id}/webhooks/subscriptions`, body)
23025
23116
  );
23026
23117
  }
23027
- /** Fetch the current webhook subscription. Returns `null` if none exists. */
23118
+ /** Fetch the account's oldest webhook endpoint. Returns `null` if none exists. */
23028
23119
  async get(accountId) {
23029
23120
  const id = this.accountId(accountId);
23030
23121
  return this.callOptional(
@@ -23032,7 +23123,7 @@ var WebhookResource = class extends BaseResource {
23032
23123
  () => this.http.get(`/accounts/${id}/webhooks/subscriptions`)
23033
23124
  );
23034
23125
  }
23035
- /** Inactivate the current webhook subscription without deleting it. */
23126
+ /** Inactivate the account's oldest webhook endpoint without deleting it. */
23036
23127
  async inactivate(accountId) {
23037
23128
  const id = this.accountId(accountId);
23038
23129
  this.logger.info("Inactivating webhook subscription");
@@ -23041,6 +23132,91 @@ var WebhookResource = class extends BaseResource {
23041
23132
  () => this.http.put(`/accounts/${id}/webhooks/inactivate`)
23042
23133
  );
23043
23134
  }
23135
+ /** `GET /accounts/{accountId}/webhooks/endpoints` — list webhook endpoints, oldest first. */
23136
+ async listEndpoints(accountId) {
23137
+ const id = this.accountId(accountId);
23138
+ return this.call(
23139
+ "Failed to list webhook endpoints",
23140
+ () => this.http.get(`/accounts/${id}/webhooks/endpoints`)
23141
+ );
23142
+ }
23143
+ /**
23144
+ * `POST /accounts/{accountId}/webhooks/endpoints` — register another
23145
+ * endpoint. Accounts allow 1 endpoint, or up to 3 on paid plans (`403` past
23146
+ * the limit); URLs must be unique per workspace. Omitted `events` uses the
23147
+ * same default set as {@link register}.
23148
+ */
23149
+ async createEndpoint(payload, accountId) {
23150
+ if (!payload.url) throw new ValidationError("Webhook URL is required");
23151
+ validateWebhookFields({ ...payload, email: payload.email ?? "" });
23152
+ const id = this.accountId(accountId);
23153
+ const body = { ...payload, events: payload.events ?? DEFAULT_EVENTS };
23154
+ this.logger.info("Creating webhook endpoint", { eventCount: body.events.length });
23155
+ return this.call(
23156
+ "Failed to create webhook endpoint",
23157
+ () => this.http.post(`/accounts/${id}/webhooks/endpoints`, body)
23158
+ );
23159
+ }
23160
+ /** `GET /accounts/{accountId}/webhooks/endpoints/{endpointId}` — fetch one endpoint. */
23161
+ async getEndpoint(endpointId, accountId) {
23162
+ const id = this.accountId(accountId);
23163
+ const eid = this.requireId(endpointId, "Endpoint ID");
23164
+ return this.call(
23165
+ "Failed to fetch webhook endpoint",
23166
+ () => this.http.get(`/accounts/${id}/webhooks/endpoints/${eid}`)
23167
+ );
23168
+ }
23169
+ /**
23170
+ * `PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}` — update only
23171
+ * the fields sent. Enabling signing creates a secret when none exists;
23172
+ * disabling it discards the secret.
23173
+ */
23174
+ async updateEndpoint(endpointId, payload, accountId) {
23175
+ const id = this.accountId(accountId);
23176
+ const eid = this.requireId(endpointId, "Endpoint ID");
23177
+ if (!payload || typeof payload !== "object" || Object.keys(payload).length === 0) {
23178
+ throw new ValidationError("At least one webhook endpoint field is required");
23179
+ }
23180
+ validateWebhookFields(payload);
23181
+ return this.call(
23182
+ "Failed to update webhook endpoint",
23183
+ () => this.http.put(`/accounts/${id}/webhooks/endpoints/${eid}`, payload)
23184
+ );
23185
+ }
23186
+ /** `DELETE /accounts/{accountId}/webhooks/endpoints/{endpointId}` — delete an endpoint and free its slot. */
23187
+ async deleteEndpoint(endpointId, accountId) {
23188
+ const id = this.accountId(accountId);
23189
+ const eid = this.requireId(endpointId, "Endpoint ID");
23190
+ return this.call(
23191
+ "Failed to delete webhook endpoint",
23192
+ () => this.http.delete(`/accounts/${id}/webhooks/endpoints/${eid}`)
23193
+ );
23194
+ }
23195
+ /**
23196
+ * `GET …/endpoints/{endpointId}/secret` — the `whsec_` signing secret.
23197
+ * Returns `400` when signing is disabled. Not available to OAuth applications.
23198
+ */
23199
+ async getEndpointSecret(endpointId, accountId) {
23200
+ const id = this.accountId(accountId);
23201
+ const eid = this.requireId(endpointId, "Endpoint ID");
23202
+ return this.call(
23203
+ "Failed to fetch webhook endpoint secret",
23204
+ () => this.http.get(`/accounts/${id}/webhooks/endpoints/${eid}/secret`)
23205
+ );
23206
+ }
23207
+ /**
23208
+ * `POST …/endpoints/{endpointId}/secret/rotate` — replace the signing secret.
23209
+ * The old secret stops working immediately. Not available to OAuth applications.
23210
+ */
23211
+ async rotateEndpointSecret(endpointId, accountId) {
23212
+ const id = this.accountId(accountId);
23213
+ const eid = this.requireId(endpointId, "Endpoint ID");
23214
+ this.logger.info("Rotating webhook endpoint secret");
23215
+ return this.call(
23216
+ "Failed to rotate webhook endpoint secret",
23217
+ () => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`)
23218
+ );
23219
+ }
23044
23220
  /** List currently supported webhook event types. */
23045
23221
  async listEventTypes() {
23046
23222
  return this.call(
@@ -23048,7 +23224,7 @@ var WebhookResource = class extends BaseResource {
23048
23224
  () => this.http.get("/webhooks/event-types")
23049
23225
  );
23050
23226
  }
23051
- /** List webhook delivery history for the workspace. */
23227
+ /** List webhook delivery history for the workspace, optionally for one endpoint. */
23052
23228
  async listDispatches(params = {}, accountId) {
23053
23229
  const id = this.accountId(accountId);
23054
23230
  if ("search" in params) throw new ValidationError("webhook dispatch search is not supported");
@@ -23060,7 +23236,7 @@ var WebhookResource = class extends BaseResource {
23060
23236
  })
23061
23237
  );
23062
23238
  }
23063
- /** Retry delivery of a specific webhook dispatch. */
23239
+ /** Retry delivery of a specific webhook dispatch to that entry's endpoint. */
23064
23240
  async retryDispatch(dispatchId, accountId) {
23065
23241
  const id = this.accountId(accountId);
23066
23242
  const did = this.requireId(dispatchId, "Dispatch ID");
@@ -23169,6 +23345,17 @@ function validateNotificationSender(value) {
23169
23345
 
23170
23346
  // src/api/support/webhook-verifier.ts
23171
23347
  var import_node_crypto2 = require("crypto");
23348
+ function readHeader(headers, name) {
23349
+ if (typeof headers.get === "function") {
23350
+ return headers.get(name) ?? void 0;
23351
+ }
23352
+ for (const [key, value] of Object.entries(headers)) {
23353
+ if (key.toLowerCase() !== name) continue;
23354
+ if (Array.isArray(value)) return value.length === 1 ? value[0] : void 0;
23355
+ return value;
23356
+ }
23357
+ return void 0;
23358
+ }
23172
23359
  var WebhookVerifier = class {
23173
23360
  constructor(webhookSecret, options = {}) {
23174
23361
  this.webhookSecret = webhookSecret;
@@ -23178,15 +23365,48 @@ var WebhookVerifier = class {
23178
23365
  webhookSecret;
23179
23366
  algorithm;
23180
23367
  encoding;
23181
- /** Returns `true` if `signature` is a valid HMAC of `payload` under the configured scheme. */
23368
+ /**
23369
+ * Returns `true` when `headers` carry a Standard Webhooks signature that
23370
+ * matches the raw `payload` under this verifier's `whsec_` secret and the
23371
+ * `webhook-timestamp` is within the tolerance window. Pass the body exactly
23372
+ * as received; re-serialized JSON does not verify.
23373
+ */
23374
+ verifyDelivery(payload, headers, options = {}) {
23375
+ if (!this.webhookSecret || !headers) return false;
23376
+ const id = readHeader(headers, "webhook-id");
23377
+ const timestamp = readHeader(headers, "webhook-timestamp");
23378
+ const signatures = readHeader(headers, "webhook-signature");
23379
+ if (!id || !timestamp || !signatures || !/^\d+$/.test(timestamp)) return false;
23380
+ const tolerance = options.toleranceSeconds ?? 300;
23381
+ const now = Math.floor((options.now ?? Date.now()) / 1e3);
23382
+ if (Math.abs(now - Number(timestamp)) > tolerance) return false;
23383
+ const secret = this.webhookSecret.startsWith("whsec_") ? this.webhookSecret.slice("whsec_".length) : this.webhookSecret;
23384
+ const key = Buffer.from(secret, "base64");
23385
+ if (key.length === 0) return false;
23386
+ const expected = Buffer.from(
23387
+ (0, import_node_crypto2.createHmac)("sha256", key).update(`${id}.${timestamp}.`).update(typeof payload === "string" ? Buffer.from(payload, "utf8") : payload).digest("base64")
23388
+ );
23389
+ return signatures.split(" ").some((entry) => {
23390
+ const [version, value] = entry.split(",", 2);
23391
+ if (version !== "v1" || !value) return false;
23392
+ const provided = Buffer.from(value);
23393
+ return provided.length === expected.length && (0, import_node_crypto2.timingSafeEqual)(provided, expected);
23394
+ });
23395
+ }
23396
+ /**
23397
+ * Returns `true` if `signature` is an HMAC of `payload` keyed with the raw
23398
+ * secret string under the configured algorithm/encoding.
23399
+ *
23400
+ * @deprecated Assinafy signs deliveries with Standard Webhooks headers; use
23401
+ * {@link verifyDelivery}. Retained for existing callers.
23402
+ */
23182
23403
  verify(payload, signature) {
23183
23404
  if (!this.webhookSecret || !signature) return false;
23184
23405
  try {
23185
23406
  const buf = typeof payload === "string" ? Buffer.from(payload, "utf8") : payload;
23186
23407
  const expected = (0, import_node_crypto2.createHmac)(this.algorithm, this.webhookSecret).update(buf).digest(this.encoding);
23187
- const provided = signature.trim();
23188
23408
  const a2 = Buffer.from(expected, "utf8");
23189
- const b = Buffer.from(provided, "utf8");
23409
+ const b = Buffer.from(signature.trim(), "utf8");
23190
23410
  if (a2.length !== b.length) return false;
23191
23411
  return (0, import_node_crypto2.timingSafeEqual)(a2, b);
23192
23412
  } catch {
@@ -23736,7 +23956,33 @@ function readConfigFile(options = {}) {
23736
23956
  }
23737
23957
  try {
23738
23958
  const parsed = JSON.parse((0, import_node_fs3.readFileSync)(file, "utf8"));
23739
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
23959
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
23960
+ if (parsed.default_profile !== void 0 && typeof parsed.default_profile !== "string") {
23961
+ throw new Error("Invalid default_profile");
23962
+ }
23963
+ if (parsed.profiles !== void 0) {
23964
+ if (!parsed.profiles || typeof parsed.profiles !== "object" || Array.isArray(parsed.profiles)) {
23965
+ throw new Error("Invalid profiles");
23966
+ }
23967
+ for (const profile of Object.values(parsed.profiles)) {
23968
+ if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
23969
+ throw new Error("Invalid profile");
23970
+ }
23971
+ for (const key of [
23972
+ "api_key",
23973
+ "token",
23974
+ "account_id",
23975
+ "base_url",
23976
+ "webhook_secret"
23977
+ ]) {
23978
+ if (profile[key] !== void 0 && typeof profile[key] !== "string") {
23979
+ throw new Error("Invalid profile field");
23980
+ }
23981
+ }
23982
+ }
23983
+ }
23984
+ return parsed;
23985
+ }
23740
23986
  if (options.strict) {
23741
23987
  throw new CliError(`Config file at ${file} is not a JSON object; refusing to overwrite it.`);
23742
23988
  }
@@ -23748,10 +23994,12 @@ function readConfigFile(options = {}) {
23748
23994
  } catch (error) {
23749
23995
  if (error instanceof CliError) throw error;
23750
23996
  if (options.strict) {
23751
- throw new CliError(`Config file at ${file} is not valid JSON; refusing to overwrite it.`);
23997
+ throw new CliError(
23998
+ `Config file at ${file} has invalid JSON or field types; refusing to overwrite it.`
23999
+ );
23752
24000
  }
23753
24001
  process.stderr.write(
23754
- `${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} is not valid JSON; ignoring it.
24002
+ `${import_picocolors3.default.yellow("!")} Config file at ${sanitizeTerminalText(file)} has invalid JSON or field types; ignoring it.
23755
24003
  `
23756
24004
  );
23757
24005
  return {};
@@ -23762,6 +24010,7 @@ function writeConfigFile(config) {
23762
24010
  if (!(0, import_node_fs3.existsSync)(dir)) {
23763
24011
  (0, import_node_fs3.mkdirSync)(dir, { recursive: true, mode: 448 });
23764
24012
  }
24013
+ if (process.platform !== "win32") (0, import_node_fs3.chmodSync)(dir, 448);
23765
24014
  const file = configPath();
23766
24015
  const tmp = `${file}.${(0, import_node_crypto3.randomUUID)()}.tmp`;
23767
24016
  try {
@@ -23784,13 +24033,13 @@ function resolveConfig2(globals) {
23784
24033
  const file = readConfigFile();
23785
24034
  const profileName = activeProfileName(globals, file);
23786
24035
  const profile = file.profiles?.[profileName] ?? {};
23787
- const pick = (flag, env, stored) => flag ?? env ?? stored;
24036
+ const pick = (flag, env, stored) => flag || env || stored || void 0;
23788
24037
  const baseUrl = pick(globals.baseUrl, process.env.ASSINAFY_BASE_URL, profile.base_url) ?? DEFAULT_BASE_URL2;
23789
24038
  const credentials = [
23790
24039
  { apiKey: globals.apiKey, token: globals.token },
23791
24040
  { apiKey: process.env.ASSINAFY_API_KEY, token: process.env.ASSINAFY_TOKEN },
23792
24041
  { apiKey: profile.api_key, token: profile.token }
23793
- ].find(({ apiKey, token }) => apiKey !== void 0 || token !== void 0);
24042
+ ].find(({ apiKey, token }) => apiKey || token);
23794
24043
  return {
23795
24044
  apiKey: credentials?.apiKey,
23796
24045
  token: credentials?.token,
@@ -25095,30 +25344,157 @@ function unwrap(value) {
25095
25344
  function resetPasswordPayload(email, resetToken, newPassword) {
25096
25345
  return { email, token: resetToken, new_password: newPassword };
25097
25346
  }
25347
+ var mfaCodeOption = () => new Option(
25348
+ "--mfa-code <code>",
25349
+ "Authenticator or recovery code (prompted if required and omitted)"
25350
+ ).env("ASSINAFY_MFA_CODE");
25351
+ var printSession = (result, config) => {
25352
+ printSuccess(`Logged in as ${result.user.email}`, config);
25353
+ printData(
25354
+ result,
25355
+ config,
25356
+ (r2) => renderKeyValue({
25357
+ access_token: r2.access_token,
25358
+ user: r2.user.email,
25359
+ accounts: r2.accounts.map((a2) => a2.id)
25360
+ })
25361
+ );
25362
+ };
25098
25363
  var loginCommand = new Command("login").description(
25099
- "Exchange email + password for a JWT access token (no existing credentials required)"
25364
+ "Exchange email + password (and a two-factor code when enabled) for a JWT access token (no existing credentials required)"
25100
25365
  ).argument("<email>", "Account email").addOption(
25101
25366
  new Option("--password <password>", "Password (prompted if omitted)").env("ASSINAFY_PASSWORD")
25102
- ).action(async (email, opts, command) => {
25367
+ ).addOption(mfaCodeOption()).action(async (email, opts, command) => {
25103
25368
  await runWithPublicClient(command, async ({ client, config }) => {
25104
25369
  const password2 = opts.password ?? await promptSecret("Password");
25105
- const result = await withSpinner(
25370
+ let result = await withSpinner(
25106
25371
  "Logging in",
25107
25372
  config,
25108
25373
  () => client.auth.login(email, password2)
25109
25374
  );
25110
- printSuccess(`Logged in as ${result.user.email}`, config);
25375
+ if (!result.access_token && result.mfa_token) {
25376
+ const mfaToken = result.mfa_token;
25377
+ const code = opts.mfaCode ?? await promptSecret("Two-factor code");
25378
+ result = await withSpinner(
25379
+ "Verifying two-factor code",
25380
+ config,
25381
+ () => client.auth.verifyMfa({ mfa_token: mfaToken, code })
25382
+ );
25383
+ }
25384
+ printSession(result, config);
25385
+ });
25386
+ });
25387
+ var mfaVerifyCommand = new Command("verify").description(
25388
+ "Complete a two-factor login with the mfa_token from login (no existing credentials required)"
25389
+ ).addOption(
25390
+ new Option("--mfa-token <token>", "Challenge token returned by login").env("ASSINAFY_MFA_TOKEN").makeOptionMandatory()
25391
+ ).addOption(mfaCodeOption()).action(async (opts, command) => {
25392
+ await runWithPublicClient(command, async ({ client, config }) => {
25393
+ const code = opts.mfaCode ?? await promptSecret("Two-factor code");
25394
+ const result = await withSpinner(
25395
+ "Verifying two-factor code",
25396
+ config,
25397
+ () => client.auth.verifyMfa({ mfa_token: opts.mfaToken, code })
25398
+ );
25399
+ printSession(result, config);
25400
+ });
25401
+ });
25402
+ var mfaListCommand = new Command("list").alias("ls").description("List enrolled two-factor methods and remaining recovery codes").action(async (_opts, command) => {
25403
+ await runWithClient(command, async ({ client, config }) => {
25404
+ const result = await withSpinner(
25405
+ "Fetching two-factor methods",
25406
+ config,
25407
+ () => client.auth.listMfaMethods()
25408
+ );
25111
25409
  printData(
25112
25410
  result,
25113
25411
  config,
25114
- (r2) => renderKeyValue({
25115
- access_token: r2.access_token,
25116
- user: r2.user.email,
25117
- accounts: r2.accounts.map((a2) => a2.id)
25412
+ (r2) => [
25413
+ renderTable(r2.methods, [
25414
+ { header: "ID", value: (m) => m.id },
25415
+ { header: "TYPE", value: (m) => m.type },
25416
+ { header: "LABEL", value: (m) => m.label },
25417
+ { header: "CONFIRMED", value: (m) => m.confirmed_at },
25418
+ { header: "LAST USED", value: (m) => m.last_used_at }
25419
+ ]),
25420
+ `Recovery codes remaining: ${r2.recovery_codes_remaining}`
25421
+ ].join("\n")
25422
+ );
25423
+ });
25424
+ });
25425
+ var mfaEnrollCommand = new Command("enroll").description("Start authenticator enrollment; prints the one-time secret and provisioning URI").option("--label <label>", "Name for the authenticator").action(async (opts, command) => {
25426
+ await runWithClient(command, async ({ client, config }) => {
25427
+ const result = await withSpinner(
25428
+ "Starting enrollment",
25429
+ config,
25430
+ () => client.auth.startTotpEnrollment(opts.label)
25431
+ );
25432
+ printSuccess(
25433
+ `Enrollment started. Confirm with: assinafy auth mfa confirm ${result.id}`,
25434
+ config
25435
+ );
25436
+ printData(result, config, (r2) => renderKeyValue({ ...r2 }));
25437
+ });
25438
+ });
25439
+ var reauthPasswordOption = () => new Option("--password <password>", "Current password").env("ASSINAFY_PASSWORD");
25440
+ async function reauthPayload(opts) {
25441
+ if (opts.password) return { password: opts.password };
25442
+ return { code: opts.mfaCode ?? await promptSecret("Authenticator or recovery code") };
25443
+ }
25444
+ var mfaConfirmCommand = new Command("confirm").description("Activate an enrolled authenticator and print the one-time recovery codes").argument("<methodId>", "Method ID returned by enroll").addOption(new Option("--code <code>", "Live code from the new authenticator")).addOption(
25445
+ new Option(
25446
+ "--password <password>",
25447
+ "Current password (only when replacing a confirmed method)"
25448
+ ).env("ASSINAFY_PASSWORD")
25449
+ ).addOption(
25450
+ new Option(
25451
+ "--reauth-code <code>",
25452
+ "Code from the current authenticator or a recovery code (only when replacing)"
25453
+ ).conflicts("password")
25454
+ ).action(async (methodId, opts, command) => {
25455
+ await runWithClient(command, async ({ client, config }) => {
25456
+ const code = opts.code ?? await promptSecret("Code from the new authenticator");
25457
+ const result = await withSpinner(
25458
+ "Confirming enrollment",
25459
+ config,
25460
+ () => client.auth.confirmTotpEnrollment({
25461
+ id: methodId,
25462
+ code,
25463
+ ...opts.password ? { password: opts.password } : {},
25464
+ ...opts.reauthCode ? { reauth_code: opts.reauthCode } : {}
25118
25465
  })
25119
25466
  );
25467
+ printSuccess("Two-factor authentication enabled. Store the recovery codes now.", config);
25468
+ printData(result, config, (r2) => r2.recovery_codes.join("\n"));
25120
25469
  });
25121
25470
  });
25471
+ var mfaRecoveryCodesCommand = new Command("recovery-codes").description("Issue ten new recovery codes and invalidate the previous set").addOption(reauthPasswordOption()).addOption(mfaCodeOption().conflicts("password")).action(async (opts, command) => {
25472
+ await runWithClient(command, async ({ client, config }) => {
25473
+ const payload = await reauthPayload(opts);
25474
+ const result = await withSpinner(
25475
+ "Regenerating recovery codes",
25476
+ config,
25477
+ () => client.auth.regenerateRecoveryCodes(payload)
25478
+ );
25479
+ printSuccess("Recovery codes regenerated. Store them now.", config);
25480
+ printData(result, config, (r2) => r2.recovery_codes.join("\n"));
25481
+ });
25482
+ });
25483
+ var mfaRemoveCommand = new Command("remove").alias("rm").description("Remove a two-factor method (the last one also discards recovery codes)").argument("<methodId>", "Method ID").addOption(reauthPasswordOption()).addOption(mfaCodeOption().conflicts("password")).option("-y, --yes", "Skip the confirmation prompt").action(async (methodId, opts, command) => {
25484
+ await runWithClient(command, async ({ client, config }) => {
25485
+ if (!await confirmDestructive(`Remove two-factor method ${methodId}?`, Boolean(opts.yes)))
25486
+ return;
25487
+ const payload = await reauthPayload(opts);
25488
+ const result = await withSpinner(
25489
+ "Removing two-factor method",
25490
+ config,
25491
+ () => client.auth.removeMfaMethod(methodId, payload)
25492
+ );
25493
+ printSuccess("Two-factor method removed", config);
25494
+ printData(result, config);
25495
+ });
25496
+ });
25497
+ var mfaCommand = new Command("mfa").description("Two-factor authentication: login verification, enrollment, and recovery codes").addCommand(mfaVerifyCommand).addCommand(mfaListCommand).addCommand(mfaEnrollCommand).addCommand(mfaConfirmCommand).addCommand(mfaRecoveryCodesCommand).addCommand(mfaRemoveCommand);
25122
25498
  var socialLoginCommand = new Command("social-login").description("Exchange a provider token for an Assinafy JWT (no existing credentials required)").addOption(
25123
25499
  new Option("--provider <provider>", "OAuth provider").choices(["google"]).makeOptionMandatory()
25124
25500
  ).addOption(
@@ -25241,7 +25617,7 @@ var apiKeyDeleteCommand = new Command("delete").alias("rm").description("Revoke
25241
25617
  });
25242
25618
  });
25243
25619
  var apiKeysCommand = new Command("api-keys").description("Manage the current user personal API key").addCommand(apiKeyCreateCommand).addCommand(apiKeyGetCommand).addCommand(apiKeyDeleteCommand);
25244
- var authCommand = new Command("auth").description("Authentication, password management, and personal API keys").addCommand(loginCommand).addCommand(socialLoginCommand).addCommand(linkSocialLoginCommand).addCommand(changePasswordCommand).addCommand(requestResetCommand).addCommand(resetPasswordCommand).addCommand(apiKeysCommand);
25620
+ var authCommand = new Command("auth").description("Authentication, password management, and personal API keys").addCommand(loginCommand).addCommand(socialLoginCommand).addCommand(linkSocialLoginCommand).addCommand(changePasswordCommand).addCommand(requestResetCommand).addCommand(resetPasswordCommand).addCommand(apiKeysCommand).addCommand(mfaCommand);
25245
25621
 
25246
25622
  // src/commands/config/index.ts
25247
25623
  var import_picocolors5 = __toESM(require_picocolors(), 1);
@@ -25843,7 +26219,7 @@ var createFromTemplateCommand = new Command("create-from-template").description(
25843
26219
  const accountId = requireAccountId(config);
25844
26220
  const signers = parseJsonArray(opts.signers, "--signers");
25845
26221
  const editorFields = parseJsonArray(opts.editorFields, "--editor-fields");
25846
- const options = clean({
26222
+ const options = stripEmpty({
25847
26223
  name: opts.name,
25848
26224
  message: opts.message,
25849
26225
  expires_at: opts.expiresAt,
@@ -25972,13 +26348,6 @@ function parseSendTokenChannel(value) {
25972
26348
  if (value === "email" || value === "whatsapp") return value;
25973
26349
  throw new CliError("--channel must be email or whatsapp");
25974
26350
  }
25975
- function clean(obj) {
25976
- const out = {};
25977
- for (const [k, v] of Object.entries(obj)) {
25978
- if (v !== void 0 && v !== null) out[k] = v;
25979
- }
25980
- return out;
25981
- }
25982
26351
  var documentsCommand = new Command("documents").description("Upload, list, download, and manage documents").addCommand(uploadCommand).addCommand(listCommand3).addCommand(searchCommand).addCommand(getCommand2).addCommand(renameCommand).addCommand(downloadCommand).addCommand(thumbnailCommand).addCommand(downloadPageCommand).addCommand(activitiesCommand).addCommand(deleteCommand).addCommand(tagsCommand).addCommand(tagsSetCommand).addCommand(tagsAddCommand).addCommand(tagsRemoveCommand).addCommand(createFromTemplateCommand).addCommand(estimateTemplateCostCommand).addCommand(verifyCommand).addCommand(statusesCommand).addCommand(publicCommand).addCommand(sendTokenCommand).addCommand(progressCommand).addCommand(waitCommand);
25983
26352
 
25984
26353
  // src/commands/fields.ts
@@ -26172,8 +26541,8 @@ var connectCommand = new Command("connect").description(
26172
26541
  "Open browser consent for a public OAuth app, receive its loopback return, and print tokens"
26173
26542
  ).addOption(clientIdOption()).option("--redirect-uri <uri>", "Exactly registered HTTPS relay URI", CLI_OAUTH_REDIRECT_URI).option(
26174
26543
  "--scope <scopes>",
26175
- "Space-separated scopes; the default requests every published scope",
26176
- "account:read documents:read documents:write templates:read templates:write webhooks:write openid profile email offline_access"
26544
+ "Space-separated scopes; the default requests the seven registered CLI scopes",
26545
+ "account:read documents:read documents:write templates:read templates:write webhooks:write offline_access"
26177
26546
  ).option("--timeout <seconds>", "Wait for browser consent (1\u2013600 seconds)", "180").option("--no-browser", "Print the authorization URL without opening the system browser").action(async (opts, command) => {
26178
26547
  await runWithPublicClient(command, async ({ client, config }) => {
26179
26548
  const timeout = parseInteger(opts.timeout, "--timeout", { min: 1 });
@@ -26207,7 +26576,7 @@ function withScopeHint(error) {
26207
26576
  if (!(error instanceof ValidationError) || error.errors.oauthError !== "invalid_scope")
26208
26577
  return error;
26209
26578
  return new ValidationError(
26210
- `${error.message}. The application is not registered for one of the requested scopes: the default requests all ten published scopes, including webhooks:write. Ask the application owner to register them, or pass --scope with the scopes it permits.`,
26579
+ `${error.message}. The application is not registered for one of the requested scopes: the CLI default requests seven registered scopes, including webhooks:write and offline_access. Ask the application owner to register them, or pass --scope with the scopes it permits.`,
26211
26580
  error.errors
26212
26581
  );
26213
26582
  }
@@ -26673,7 +27042,7 @@ var getCommand4 = new Command("get").description("Show a signer by ID").argument
26673
27042
  printData(signer, config, (s) => renderKeyValue(s));
26674
27043
  });
26675
27044
  });
26676
- var updateCommand2 = new Command("update").description("Update a signer").argument("<id>", "Signer ID").option("--name <name>", "Signer full name").option("--email <email>", "Email address").option("--phone <number>", "WhatsApp phone number (E.164)").option("--cpf <cpf>", "Brazilian tax ID (CPF)").action(async (id, opts, command) => {
27045
+ var updateCommand2 = new Command("update").description("Update a signer").argument("<id>", "Signer ID").option("--name <name>", "Signer full name").option("--email <email>", "Email address").option("--phone <number>", "WhatsApp phone number (E.164)").option("--cpf <cpf>", "Brazilian tax ID (CPF/CNPJ), sent as government_id").action(async (id, opts, command) => {
26677
27046
  await runWithClient(command, async ({ client, config }) => {
26678
27047
  const accountId = requireAccountId(config);
26679
27048
  const payload = {};
@@ -26903,7 +27272,7 @@ var preferencesCommand = new Command("notification-preferences").alias("preferen
26903
27272
  var usersCommand = new Command("users").description("Show the authenticated user and personal preferences").addCommand(selfCommand2).addCommand(statsCommand).addCommand(preferencesCommand);
26904
27273
 
26905
27274
  // src/commands/webhooks.ts
26906
- var registerCommand = new Command("register").description("Register (or replace) the workspace webhook subscription").requiredOption("--url <url>", "Endpoint URL to receive events").requiredOption("--email <email>", "Contact email for delivery problems").option("--events <csv>", "Comma-separated event names (defaults to a sensible set)").option("--inactive", "Register the subscription as inactive").action(async (opts, command) => {
27275
+ var registerCommand = new Command("register").description("Register (or replace) the account's oldest webhook endpoint").requiredOption("--url <url>", "Endpoint URL to receive events").requiredOption("--email <email>", "Contact email for delivery problems").option("--events <csv>", "Comma-separated event names (defaults to a sensible set)").option("--inactive", "Register the subscription as inactive").action(async (opts, command) => {
26907
27276
  await runWithClient(command, async ({ client, config }) => {
26908
27277
  const accountId = requireAccountId(config);
26909
27278
  const events = splitList(opts.events);
@@ -26923,7 +27292,7 @@ var registerCommand = new Command("register").description("Register (or replace)
26923
27292
  );
26924
27293
  });
26925
27294
  });
26926
- var getCommand6 = new Command("get").description("Show the current webhook subscription").action(async (_opts, command) => {
27295
+ var getCommand6 = new Command("get").description("Show the account's oldest webhook endpoint").action(async (_opts, command) => {
26927
27296
  await runWithClient(command, async ({ client, config }) => {
26928
27297
  const accountId = requireAccountId(config);
26929
27298
  const sub = await withSpinner(
@@ -26942,7 +27311,7 @@ var getCommand6 = new Command("get").description("Show the current webhook subsc
26942
27311
  );
26943
27312
  });
26944
27313
  });
26945
- var inactivateCommand = new Command("inactivate").description("Inactivate the webhook subscription without deleting it").action(async (_opts, command) => {
27314
+ var inactivateCommand = new Command("inactivate").description("Inactivate the account's oldest webhook endpoint without deleting it").action(async (_opts, command) => {
26946
27315
  await runWithClient(command, async ({ client, config }) => {
26947
27316
  const accountId = requireAccountId(config);
26948
27317
  const sub = await withSpinner(
@@ -26972,12 +27341,13 @@ var eventTypesCommand = new Command("event-types").description("List supported w
26972
27341
  });
26973
27342
  });
26974
27343
  var dispatchesCommand = addSortableListOptions(
26975
- new Command("dispatches").description("List webhook delivery history").option("--event <event>", "Filter by event name").option("--delivered <bool>", "Filter by delivery status (true/false)").option("--from <unix>", "Start of time range (unix seconds)").option("--to <unix>", "End of time range (unix seconds)"),
27344
+ new Command("dispatches").description("List webhook delivery history").option("--endpoint <endpointId>", "Only deliveries to this webhook endpoint").option("--event <event>", "Filter by event name").option("--delivered <bool>", "Filter by delivery status (true/false)").option("--from <unix>", "Start of time range (unix seconds)").option("--to <unix>", "End of time range (unix seconds)"),
26976
27345
  "Sort by created_at (prefix with - for descending)"
26977
27346
  ).action(async (opts, command) => {
26978
27347
  await runWithClient(command, async ({ client, config }) => {
26979
27348
  const accountId = requireAccountId(config);
26980
27349
  const params = { ...listParams(opts) };
27350
+ if (opts.endpoint) params.endpoint_id = opts.endpoint;
26981
27351
  if (opts.event) params.event = opts.event;
26982
27352
  if (opts.delivered !== void 0) {
26983
27353
  const v = opts.delivered.toLowerCase();
@@ -27023,7 +27393,144 @@ var retryCommand = new Command("retry").description("Retry delivery of a specifi
27023
27393
  );
27024
27394
  });
27025
27395
  });
27026
- var webhooksCommand = new Command("webhooks").description("Manage webhook subscriptions and delivery history").addCommand(registerCommand).addCommand(getCommand6).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand);
27396
+ var renderEndpoint = (e) => renderKeyValue({
27397
+ id: e.id,
27398
+ name: e.name,
27399
+ url: e.url,
27400
+ email: e.email,
27401
+ is_active: e.is_active,
27402
+ signing_enabled: e.signing_enabled,
27403
+ events: e.events
27404
+ });
27405
+ function endpointFieldOptions(command) {
27406
+ return command.option("--name <name>", "Label to tell endpoints apart").option("--events <csv>", "Comma-separated event names").addOption(new Option("--active", "Deliver events to this endpoint")).addOption(new Option("--inactive", "Stop delivering events").conflicts("active")).addOption(new Option("--signing", "Sign deliveries (Standard Webhooks)")).addOption(
27407
+ new Option("--no-signing", "Disable signing and discard the secret").default(void 0)
27408
+ );
27409
+ }
27410
+ function endpointPayload(opts) {
27411
+ const payload = {};
27412
+ if (opts.url !== void 0) payload.url = opts.url;
27413
+ if (opts.email !== void 0) payload.email = opts.email;
27414
+ if (opts.name !== void 0) payload.name = opts.name;
27415
+ const events = splitList(opts.events);
27416
+ if (events !== void 0) payload.events = events;
27417
+ if (opts.active || opts.inactive) payload.is_active = Boolean(opts.active);
27418
+ if (opts.signing !== void 0) payload.signing_enabled = opts.signing;
27419
+ return payload;
27420
+ }
27421
+ var endpointsListCommand = new Command("list").alias("ls").description("List webhook endpoints, oldest first").action(async (_opts, command) => {
27422
+ await runWithClient(command, async ({ client, config }) => {
27423
+ const accountId = requireAccountId(config);
27424
+ const rows = await withSpinner(
27425
+ "Fetching endpoints",
27426
+ config,
27427
+ () => client.webhooks.listEndpoints(accountId)
27428
+ );
27429
+ printData(
27430
+ rows,
27431
+ config,
27432
+ (list) => renderTable(list, [
27433
+ { header: "ID", value: (r2) => r2.id },
27434
+ { header: "NAME", value: (r2) => r2.name },
27435
+ { header: "URL", value: (r2) => r2.url },
27436
+ { header: "ACTIVE", value: (r2) => r2.is_active },
27437
+ { header: "SIGNED", value: (r2) => r2.signing_enabled }
27438
+ ])
27439
+ );
27440
+ });
27441
+ });
27442
+ var endpointsCreateCommand = endpointFieldOptions(
27443
+ new Command("create").description("Register a webhook endpoint (1 per account, up to 3 on paid plans)").requiredOption("--url <url>", "Endpoint URL to receive events").requiredOption("--email <email>", "Contact email for delivery problems")
27444
+ ).action(async (opts, command) => {
27445
+ await runWithClient(command, async ({ client, config }) => {
27446
+ const accountId = requireAccountId(config);
27447
+ const endpoint = await withSpinner(
27448
+ "Creating endpoint",
27449
+ config,
27450
+ () => client.webhooks.createEndpoint(
27451
+ { ...endpointPayload(opts), url: opts.url, email: opts.email },
27452
+ accountId
27453
+ )
27454
+ );
27455
+ printSuccess("Webhook endpoint created", config);
27456
+ printData(endpoint, config, renderEndpoint);
27457
+ });
27458
+ });
27459
+ var endpointsGetCommand = new Command("get").description("Show one webhook endpoint").argument("<endpointId>", "Endpoint ID").action(async (endpointId, _opts, command) => {
27460
+ await runWithClient(command, async ({ client, config }) => {
27461
+ const accountId = requireAccountId(config);
27462
+ const endpoint = await withSpinner(
27463
+ "Fetching endpoint",
27464
+ config,
27465
+ () => client.webhooks.getEndpoint(endpointId, accountId)
27466
+ );
27467
+ printData(endpoint, config, renderEndpoint);
27468
+ });
27469
+ });
27470
+ var endpointsUpdateCommand = endpointFieldOptions(
27471
+ new Command("update").description("Update the given fields of a webhook endpoint").argument("<endpointId>", "Endpoint ID").option("--url <url>", "Endpoint URL to receive events").option("--email <email>", "Contact email for delivery problems")
27472
+ ).action(async (endpointId, opts, command) => {
27473
+ await runWithClient(command, async ({ client, config }) => {
27474
+ const accountId = requireAccountId(config);
27475
+ const payload = endpointPayload(opts);
27476
+ if (Object.keys(payload).length === 0) {
27477
+ throw new CliError("Provide at least one field to update");
27478
+ }
27479
+ const endpoint = await withSpinner(
27480
+ "Updating endpoint",
27481
+ config,
27482
+ () => client.webhooks.updateEndpoint(endpointId, payload, accountId)
27483
+ );
27484
+ printSuccess("Webhook endpoint updated", config);
27485
+ printData(endpoint, config, renderEndpoint);
27486
+ });
27487
+ });
27488
+ var endpointsDeleteCommand = new Command("delete").alias("rm").description("Delete a webhook endpoint and free its slot").argument("<endpointId>", "Endpoint ID").option("-y, --yes", "Skip the confirmation prompt").action(async (endpointId, opts, command) => {
27489
+ await runWithClient(command, async ({ client, config }) => {
27490
+ const accountId = requireAccountId(config);
27491
+ if (!await confirmDestructive(`Delete webhook endpoint ${endpointId}?`, Boolean(opts.yes)))
27492
+ return;
27493
+ await withSpinner(
27494
+ "Deleting endpoint",
27495
+ config,
27496
+ () => client.webhooks.deleteEndpoint(endpointId, accountId)
27497
+ );
27498
+ printSuccess("Webhook endpoint deleted", config);
27499
+ printData({ id: endpointId, deleted: true }, config);
27500
+ });
27501
+ });
27502
+ var endpointsSecretCommand = new Command("secret").description(
27503
+ "Print the endpoint signing secret (signing must be enabled; not available via OAuth)"
27504
+ ).argument("<endpointId>", "Endpoint ID").action(async (endpointId, _opts, command) => {
27505
+ await runWithClient(command, async ({ client, config }) => {
27506
+ const accountId = requireAccountId(config);
27507
+ const result = await withSpinner(
27508
+ "Fetching secret",
27509
+ config,
27510
+ () => client.webhooks.getEndpointSecret(endpointId, accountId)
27511
+ );
27512
+ printData(result, config, (r2) => r2.secret);
27513
+ });
27514
+ });
27515
+ var endpointsRotateSecretCommand = new Command("rotate-secret").description("Replace the endpoint signing secret; the old one stops working immediately").argument("<endpointId>", "Endpoint ID").option("-y, --yes", "Skip the confirmation prompt").action(async (endpointId, opts, command) => {
27516
+ await runWithClient(command, async ({ client, config }) => {
27517
+ const accountId = requireAccountId(config);
27518
+ if (!await confirmDestructive(
27519
+ `Rotate the signing secret of ${endpointId}? The current secret stops working immediately.`,
27520
+ Boolean(opts.yes)
27521
+ ))
27522
+ return;
27523
+ const result = await withSpinner(
27524
+ "Rotating secret",
27525
+ config,
27526
+ () => client.webhooks.rotateEndpointSecret(endpointId, accountId)
27527
+ );
27528
+ printSuccess("Signing secret rotated", config);
27529
+ printData(result, config, (r2) => r2.secret);
27530
+ });
27531
+ });
27532
+ var endpointsCommand = new Command("endpoints").description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
27533
+ var webhooksCommand = new Command("webhooks").description("Manage webhook endpoints, the primary subscription, and delivery history").addCommand(endpointsCommand).addCommand(registerCommand).addCommand(getCommand6).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand);
27027
27534
 
27028
27535
  // src/commands/whoami.ts
27029
27536
  var whoamiCommand = new Command("whoami").description("Verify credentials and list the workspaces they can access").action(async (_opts, command) => {
@@ -27246,7 +27753,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
27246
27753
  // package.json
27247
27754
  var package_default = {
27248
27755
  name: "@assinafy/cli",
27249
- version: "2.4.1",
27756
+ version: "2.5.0",
27250
27757
  description: "The official command-line interface for the Assinafy digital-signature API",
27251
27758
  license: "MIT",
27252
27759
  type: "module",