@assinafy/sdk 2.6.0 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -55,6 +55,25 @@ var ApiError = class _ApiError extends AssinafyError {
55
55
  * ```
56
56
  */
57
57
  challenge;
58
+ /**
59
+ * Rate-limit headers carried by the failed response: `X-Rate-Limit-Limit`,
60
+ * `X-Rate-Limit-Remaining`, `X-Rate-Limit-Reset` and, on `429`,
61
+ * `Retry-After` (all in requests or seconds). `undefined` when the response
62
+ * carried none of them. The client already retries a `429` up to
63
+ * `maxRetries` times; this is what remains once those retries are spent.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * try {
68
+ * await client.documents.list();
69
+ * } catch (error) {
70
+ * if (error instanceof ApiError && error.statusCode === 429) {
71
+ * await sleep((error.rateLimit?.retryAfter ?? 60) * 1000);
72
+ * }
73
+ * }
74
+ * ```
75
+ */
76
+ rateLimit;
58
77
  /**
59
78
  * Create an error representing a non-success API response.
60
79
  *
@@ -98,7 +117,7 @@ var ApiError = class _ApiError extends AssinafyError {
98
117
  const data = responseData ?? {};
99
118
  const rawMessage = data["message"];
100
119
  const rawError = data["error"];
101
- const message = typeof rawMessage === "string" && rawMessage.length > 0 ? rawMessage : typeof rawError === "string" ? rawError : FALLBACK_MESSAGE;
120
+ const message = typeof rawMessage === "string" && rawMessage.length > 0 ? rawMessage : typeof rawError === "string" && rawError.length > 0 ? rawError : FALLBACK_MESSAGE;
102
121
  return new _ApiError(message, statusCode, responseData);
103
122
  }
104
123
  };
@@ -160,6 +179,7 @@ var OAuthError = class _OAuthError extends ApiError {
160
179
  body
161
180
  );
162
181
  if (error.challenge !== void 0) upgraded.challenge = error.challenge;
182
+ if (error.rateLimit !== void 0) upgraded.rateLimit = error.rateLimit;
163
183
  return upgraded;
164
184
  }
165
185
  };
@@ -237,6 +257,20 @@ function parseWwwAuthenticate(value) {
237
257
  }
238
258
  return challenge;
239
259
  }
260
+ var RATE_LIMIT_HEADERS = [
261
+ ["limit", "x-rate-limit-limit"],
262
+ ["remaining", "x-rate-limit-remaining"],
263
+ ["reset", "x-rate-limit-reset"],
264
+ ["retryAfter", "retry-after"]
265
+ ];
266
+ function parseRateLimit(headers) {
267
+ const info = {};
268
+ for (const [key, header2] of RATE_LIMIT_HEADERS) {
269
+ const value = readHeader(headers, header2)?.trim();
270
+ if (value !== void 0 && /^\d+$/u.test(value)) info[key] = Number(value);
271
+ }
272
+ return Object.keys(info).length > 0 ? info : void 0;
273
+ }
240
274
 
241
275
  // src/utils.ts
242
276
  var SAFE_LOG_NUMBER_FIELDS = /* @__PURE__ */ new Set([
@@ -283,10 +317,11 @@ function toSdkError(error, fallbackMessage) {
283
317
  if (status) {
284
318
  const body = decodeBinaryErrorBody(error.response?.data ?? null);
285
319
  const apiError = ApiError.fromResponse(status, body ?? null);
286
- const challenge = parseWwwAuthenticate(
287
- readHeader(error.response?.headers, "www-authenticate")
288
- );
320
+ const headers = error.response?.headers;
321
+ const challenge = parseWwwAuthenticate(readHeader(headers, "www-authenticate"));
289
322
  if (challenge) apiError.challenge = challenge;
323
+ const rateLimit = parseRateLimit(headers);
324
+ if (rateLimit) apiError.rateLimit = rateLimit;
290
325
  return apiError;
291
326
  }
292
327
  const cause = sanitiseNetworkCause(error);
@@ -395,15 +430,16 @@ function assertDocumentArtifactName(value) {
395
430
  }
396
431
  function serializeJsonRecord(value, label) {
397
432
  assertRecord(value, label);
433
+ let serialized;
398
434
  try {
399
- const serialized = JSON.stringify(value);
400
- if (typeof serialized !== "string" || !serialized.startsWith("{")) {
401
- throw new ValidationError(`${label} must serialize to a JSON object`);
402
- }
403
- return serialized;
435
+ serialized = JSON.stringify(value);
404
436
  } catch {
405
437
  throw new ValidationError(`${label} must be JSON-serializable`);
406
438
  }
439
+ if (typeof serialized !== "string" || !serialized.startsWith("{")) {
440
+ throw new ValidationError(`${label} must serialize to a JSON object`);
441
+ }
442
+ return serialized;
407
443
  }
408
444
  function assertDateTime(value, label) {
409
445
  if (typeof value !== "string") throw new ValidationError(`${label} must be an ISO-8601 date-time`);
@@ -591,7 +627,7 @@ import axios2 from "axios";
591
627
  // package.json
592
628
  var package_default = {
593
629
  name: "@assinafy/sdk",
594
- version: "2.6.0",
630
+ version: "2.7.1",
595
631
  packageManager: "bun@1.4.0",
596
632
  description: "TypeScript SDK for Assinafy API - Digital signature platform",
597
633
  type: "commonjs",
@@ -654,7 +690,7 @@ var package_default = {
654
690
  bugs: {
655
691
  url: "https://github.com/assinafy/typescript-sdk/issues"
656
692
  },
657
- homepage: "https://github.com/assinafy/typescript-sdk/#readme",
693
+ homepage: "https://www.assinafy.com.br",
658
694
  devDependencies: {
659
695
  "@arethetypeswrong/cli": "^0.18.5",
660
696
  "@eslint/js": "^10.0.1",
@@ -1485,9 +1521,10 @@ var AssignmentResource = class extends BaseResource {
1485
1521
  * Update the expiration date of an existing assignment
1486
1522
  * (`PUT /documents/{documentId}/assignments/{assignmentId}/reset-expiration`).
1487
1523
  *
1488
- * Sends `{ expires_at }` verbatim. Use an ISO-8601 date/time string; `null`
1489
- * is retained as a compatibility value and, unlike ordinary nullable
1490
- * inputs, is intentionally not stripped from the body.
1524
+ * Sends `{ expires_at }` verbatim; the key itself is required by the
1525
+ * contract. Use an ISO-8601 date/time string, or `null` to remove the
1526
+ * expiration — `null` is the documented clear mechanism and, unlike
1527
+ * ordinary nullable inputs, is intentionally not stripped from the body.
1491
1528
  *
1492
1529
  * Request body (`application/json`):
1493
1530
  * ```jsonc
@@ -1498,8 +1535,8 @@ var AssignmentResource = class extends BaseResource {
1498
1535
  *
1499
1536
  * @param documentId - The document the assignment belongs to.
1500
1537
  * @param assignmentId - The assignment to update.
1501
- * @param expiresAt - New expiry as an ISO-8601 date/time string. `null` is
1502
- * a compatibility value intended to clear it.
1538
+ * @param expiresAt - New expiry as an ISO-8601 date/time string, or `null`
1539
+ * to remove the expiration.
1503
1540
  * @returns The updated {@link IAssignment} — the same full shape
1504
1541
  * {@link AssignmentResource.create} returns (`signers`, `items`, `summary`,
1505
1542
  * `signing_urls`), with `expires_at` reflecting the new value:
@@ -2762,32 +2799,63 @@ var DocumentResource = class extends BaseResource {
2762
2799
  () => this.publicHttp.get(`/public/documents/${this.pathSegment(id, "Document ID")}`)
2763
2800
  );
2764
2801
  }
2765
- async sendToken(documentId, recipient, channel) {
2802
+ /**
2803
+ * Email the signer the verification token that unlocks a document
2804
+ * (`PUT /public/documents/{documentId}/send-token`).
2805
+ *
2806
+ * Part of the public signing flow: dispatches the 6-digit verification
2807
+ * token the signer enters to view the document. Runs on the
2808
+ * credential-free transport. The contract accepts only the `email`
2809
+ * channel, and both body fields are required.
2810
+ *
2811
+ * Request body (`application/json`):
2812
+ * ```jsonc
2813
+ * { "channel": "email", "recipient": "signer@example.com" }
2814
+ * ```
2815
+ *
2816
+ * @param documentId - The document to send the token for.
2817
+ * @param recipient - The signer's email address.
2818
+ * @param channel - Delivery channel; only `email` is accepted (default).
2819
+ * @returns The delivery confirmation (`data` of the envelope):
2820
+ * ```jsonc
2821
+ * {
2822
+ * "document": {
2823
+ * "resource": "document",
2824
+ * "id": "a1b2c3d4e5f6a7b8c9d0",
2825
+ * "name": "Contract.pdf",
2826
+ * "page_count": 3,
2827
+ * "created_by": "Jane Doe"
2828
+ * },
2829
+ * "channel": "email",
2830
+ * "recipient": "signer@example.com"
2831
+ * }
2832
+ * ```
2833
+ * @throws {ValidationError} If `documentId` is missing, `recipient` is not
2834
+ * a valid email address, or `channel` is not `email`.
2835
+ * @throws {ApiError} `400` if validation fails; `404` if the document does
2836
+ * not exist.
2837
+ *
2838
+ * @example
2839
+ * ```ts
2840
+ * const sent = await client.documents.sendToken('doc-1', 'signer@example.com');
2841
+ * console.log(sent.recipient);
2842
+ * ```
2843
+ */
2844
+ async sendToken(documentId, recipient, channel = "email") {
2766
2845
  const id = this.requireId(documentId, "Document ID");
2767
- assertNonEmptyString(recipient, "recipient");
2768
- if (channel !== void 0) assertNonEmptyString(channel, "channel");
2769
- if (channel === void 0 && !isEmail(recipient)) {
2770
- throw new ValidationError("recipient must be a valid email address");
2771
- }
2772
- const path2 = `/public/documents/${this.pathSegment(id, "Document ID")}/send-token`;
2773
- if (channel !== void 0) {
2774
- return this.callVoid(
2775
- "Failed to send signing token",
2776
- () => this.publicHttp.put(path2, { recipient, channel })
2777
- );
2846
+ if (channel !== "email") {
2847
+ throw new ValidationError('channel must be "email"', { channel });
2778
2848
  }
2779
- try {
2780
- return await this.callVoid(
2781
- "Failed to send signing token",
2782
- () => this.publicHttp.put(path2, { email: recipient })
2783
- );
2784
- } catch (error) {
2785
- if (!isLegacySendTokenValidation(error)) throw error;
2786
- return this.callVoid(
2787
- "Failed to send signing token",
2788
- () => this.publicHttp.put(path2, { recipient, channel: "email" })
2789
- );
2849
+ if (!isEmail(recipient)) {
2850
+ throw new ValidationError("recipient must be a valid email address");
2790
2851
  }
2852
+ return this.call(
2853
+ "Failed to send signing token",
2854
+ () => this.publicHttp.put(
2855
+ `/public/documents/${this.pathSegment(id, "Document ID")}/send-token`,
2856
+ { channel, recipient }
2857
+ )
2858
+ );
2791
2859
  }
2792
2860
  /**
2793
2861
  * Quick boolean check (`GET /documents/{documentId}`): has every signer
@@ -2933,23 +3001,6 @@ function validateWaitOption(value, name) {
2933
3001
  function sleep(ms) {
2934
3002
  return new Promise((resolve) => setTimeout(resolve, ms));
2935
3003
  }
2936
- function isLegacySendTokenValidation(error) {
2937
- if (!(error instanceof ApiError) || error.statusCode !== 400 && error.statusCode !== 422) {
2938
- return false;
2939
- }
2940
- const namesLegacyField = /\b(?:channel|recipient)\b/iu.test(error.message);
2941
- const saysRequired = /\b(?:required|obrigat[oó]ri[oa])\b/iu.test(error.message);
2942
- if (namesLegacyField && saysRequired) return true;
2943
- const response = error.responseData;
2944
- if (!response || typeof response !== "object" || Array.isArray(response)) return false;
2945
- const errors = response["errors"];
2946
- if (!errors || typeof errors !== "object" || Array.isArray(errors)) return false;
2947
- return ["channel", "recipient"].some((field) => {
2948
- if (!Object.hasOwn(errors, field)) return false;
2949
- const detail = JSON.stringify(errors[field]);
2950
- return /required|obrigat[oó]ri[oa]/iu.test(detail);
2951
- });
2952
- }
2953
3004
 
2954
3005
  // src/resources/signers.ts
2955
3006
  var SignerResource = class extends BaseResource {
@@ -4748,7 +4799,7 @@ var TemplateResource = class extends BaseResource {
4748
4799
  * ```ts
4749
4800
  * const tmpl = await client.templates.get('103ad2171db7979468c3e97eb067');
4750
4801
  * const jpeg = await client.templates.downloadPage(tmpl.id, tmpl.pages[0].id);
4751
- * await fs.writeFile('page-1.jpg', jpeg);
4802
+ * await fs.promises.writeFile('page-1.jpg', jpeg);
4752
4803
  * ```
4753
4804
  */
4754
4805
  async downloadPage(templateId, pageId, accountId) {
@@ -5085,10 +5136,10 @@ var AuthenticationResource = class extends BaseResource {
5085
5136
  * ]
5086
5137
  * }
5087
5138
  * ```
5088
- * @throws {ValidationError} If `email` or `password` is missing.
5089
5139
  * When the user has two-factor authentication enabled the response carries
5090
5140
  * an `mfa_token` instead of a usable session; finish with
5091
5141
  * {@link AuthenticationResource.verifyMfa}.
5142
+ * @throws {ValidationError} If `email` or `password` is missing.
5092
5143
  * @throws {ApiError} `400` if the credentials are rejected.
5093
5144
  *
5094
5145
  * @example
@@ -5236,13 +5287,6 @@ var AuthenticationResource = class extends BaseResource {
5236
5287
  * Link a Google identity to the authenticated user
5237
5288
  * (`POST /auth/link-social-login`).
5238
5289
  *
5239
- * Request body:
5240
- * ```jsonc
5241
- * { "provider": "google", "token": "provider-issued-token" }
5242
- * ```
5243
- * The response is the standard status/message acknowledgement with no data,
5244
- * so this method resolves to `void`.
5245
- *
5246
5290
  * Request body (`application/json`):
5247
5291
  * ```jsonc
5248
5292
  * {
@@ -5250,6 +5294,8 @@ var AuthenticationResource = class extends BaseResource {
5250
5294
  * "token": "provider_token_example"
5251
5295
  * }
5252
5296
  * ```
5297
+ * The response is the standard status/message acknowledgement with no data,
5298
+ * so this method resolves to `void`.
5253
5299
  *
5254
5300
  * @param payload - Social provider and provider-issued access/ID token.
5255
5301
  * @returns Resolves when the API acknowledges that the identity was linked.
@@ -6006,6 +6052,11 @@ var OAuthResource = class extends BaseResource {
6006
6052
  * already-revoked included — so the endpoint cannot be used to probe
6007
6053
  * whether a token exists. Only failed client authentication returns `401`.
6008
6054
  *
6055
+ * Request body (`application/x-www-form-urlencoded`):
6056
+ * ```text
6057
+ * token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
6058
+ * ```
6059
+ *
6009
6060
  * @param options - Revocation options.
6010
6061
  * @param options.token - The access or refresh token to revoke.
6011
6062
  * @param options.clientId - The application's `client_id`.
@@ -6014,10 +6065,6 @@ var OAuthResource = class extends BaseResource {
6014
6065
  * @param options.tokenTypeHint - Optional `access_token` or
6015
6066
  * `refresh_token` hint that lets the server skip a lookup.
6016
6067
  * @returns Nothing; resolves once the API acknowledges the request.
6017
- * Request body (`application/x-www-form-urlencoded`):
6018
- * ```text
6019
- * token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
6020
- * ```
6021
6068
  * @throws {ValidationError} If `token` or `clientId` is missing, or
6022
6069
  * `tokenTypeHint` is not one of the two documented values.
6023
6070
  * @throws {OAuthError} `invalid_client` when client authentication fails.
@@ -6666,7 +6713,14 @@ function validateSignerAccessCode(value) {
6666
6713
  var SignerDocumentsResource = class extends BaseResource {
6667
6714
  constructor(http, defaultAccountId, logger, publicHttp) {
6668
6715
  super(withoutCredentials(publicHttp ?? http), defaultAccountId, logger);
6716
+ this.workspaceHttp = http;
6669
6717
  }
6718
+ /**
6719
+ * Credentialed transport used only by the explicit `*AsWorkspace` methods.
6720
+ * Every access-code method stays on the credential-free `http`, so a
6721
+ * signer code and the API key or bearer token never share a request.
6722
+ */
6723
+ workspaceHttp;
6670
6724
  /**
6671
6725
  * Fetch the document currently awaiting a given signer
6672
6726
  * (`GET /signers/{signer_id}/document?signer-access-code=…`).
@@ -6839,6 +6893,73 @@ var SignerDocumentsResource = class extends BaseResource {
6839
6893
  })
6840
6894
  );
6841
6895
  }
6896
+ /**
6897
+ * List a signer's documents with the workspace credentials
6898
+ * (`GET /signers/{signer_id}/documents`).
6899
+ *
6900
+ * The same operation as {@link SignerDocumentsResource.list}, authorised by
6901
+ * the client's API key or OAuth bearer token instead of a signer access
6902
+ * code. No `signer-access-code` is sent.
6903
+ *
6904
+ * @param signerId - The signer whose documents are listed.
6905
+ * @param params - Pagination: `page`, `per-page` (also accepts `per_page`).
6906
+ * @returns Documents in the compact {@link IDocumentListItem} shape, with
6907
+ * pagination in `meta` (same shape as {@link SignerDocumentsResource.list}):
6908
+ * ```jsonc
6909
+ * {
6910
+ * "data": [{ "id": "103acccd24234c07858ffddf6d84", "name": "Service agreement.pdf", "status": "pending_signature" }],
6911
+ * "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
6912
+ * }
6913
+ * ```
6914
+ * @throws {ValidationError} If `signerId` is missing.
6915
+ * @throws {ApiError} `401` if the workspace credentials are rejected.
6916
+ *
6917
+ * @example
6918
+ * ```ts
6919
+ * const { data } = await client.signerDocuments.listAsWorkspace(signerId, { page: 1 });
6920
+ * ```
6921
+ */
6922
+ async listAsWorkspace(signerId, params = {}) {
6923
+ const sid = this.pathSegment(signerId, "Signer ID");
6924
+ return this.callList(
6925
+ "Failed to list signer documents",
6926
+ () => this.workspaceHttp.get(`/signers/${sid}/documents`, {
6927
+ params: cleanListParams(params)
6928
+ })
6929
+ );
6930
+ }
6931
+ /**
6932
+ * Search a signer's documents with the workspace credentials
6933
+ * (`GET /signers/{signer_id}/documents/search`).
6934
+ *
6935
+ * The same operation as {@link SignerDocumentsResource.search}, authorised
6936
+ * by the client's API key or OAuth bearer token instead of a signer access
6937
+ * code. No `signer-access-code` is sent.
6938
+ *
6939
+ * @param signerId - The signer whose documents are searched.
6940
+ * @param search - Free-text term matched against the document name.
6941
+ * @returns Matching documents with pagination in `meta`, as
6942
+ * {@link SignerDocumentsResource.listAsWorkspace} returns.
6943
+ * @throws {ValidationError} If `signerId` is missing or `search` is not a string.
6944
+ * @throws {ApiError} `401` if the workspace credentials are rejected.
6945
+ *
6946
+ * @example
6947
+ * ```ts
6948
+ * const { data } = await client.signerDocuments.searchAsWorkspace(signerId, 'agreement');
6949
+ * ```
6950
+ */
6951
+ async searchAsWorkspace(signerId, search) {
6952
+ const sid = this.pathSegment(signerId, "Signer ID");
6953
+ if (search !== void 0 && typeof search !== "string") {
6954
+ throw new ValidationError("search must be a string");
6955
+ }
6956
+ return this.callList(
6957
+ "Failed to search signer documents",
6958
+ () => this.workspaceHttp.get(`/signers/${sid}/documents/search`, {
6959
+ params: cleanParams({ search })
6960
+ })
6961
+ );
6962
+ }
6842
6963
  /**
6843
6964
  * Download one of a signer's document artifacts as raw bytes
6844
6965
  * (`GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`).
@@ -6872,7 +6993,7 @@ var SignerDocumentsResource = class extends BaseResource {
6872
6993
  * documentId,
6873
6994
  * 'original',
6874
6995
  * );
6875
- * await fs.writeFile('to-sign.pdf', pdf);
6996
+ * await fs.promises.writeFile('to-sign.pdf', pdf);
6876
6997
  * ```
6877
6998
  */
6878
6999
  async download(signerId, documentId, artifactName, signerAccessCode) {
@@ -7179,7 +7300,7 @@ var SignerDocumentsResource = class extends BaseResource {
7179
7300
  * @example
7180
7301
  * ```ts
7181
7302
  * const png = await client.signerDocuments.downloadSignature(accessCode, 'signature');
7182
- * await fs.writeFile('signature.png', png);
7303
+ * await fs.promises.writeFile('signature.png', png);
7183
7304
  * ```
7184
7305
  */
7185
7306
  async downloadSignature(signerAccessCode, imageType = "signature") {
@@ -7421,6 +7542,9 @@ function assertDeclineReason(declineReason) {
7421
7542
  if (typeof declineReason !== "string" || !declineReason.trim()) {
7422
7543
  throw new ValidationError("declineReason is required");
7423
7544
  }
7545
+ if (declineReason.length > 2e3) {
7546
+ throw new ValidationError("declineReason must be at most 2000 characters");
7547
+ }
7424
7548
  }
7425
7549
  function validateConfirmDataPayload(payload) {
7426
7550
  for (const key of ["full_name", "government_id"]) {
@@ -7986,9 +8110,8 @@ function decodeSecret(secret) {
7986
8110
  return key.length > 0 ? key : null;
7987
8111
  }
7988
8112
  function header(headers, name) {
7989
- const value = typeof headers.get === "function" ? headers.get(name) : headers[name];
7990
- const first = Array.isArray(value) ? value[0] : value;
7991
- return typeof first === "string" ? first.trim() : void 0;
8113
+ const value = typeof headers.get === "function" ? headers.get(name) ?? void 0 : readHeader(headers, name);
8114
+ return typeof value === "string" ? value.trim() : void 0;
7992
8115
  }
7993
8116
  function isRecord(value) {
7994
8117
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -8125,7 +8248,7 @@ var AssinafyClient = class _AssinafyClient {
8125
8248
  );
8126
8249
  this.fields = new FieldsResource(this.axiosInstance, this.defaultAccountId, this.logger);
8127
8250
  this.signerDocuments = new SignerDocumentsResource(
8128
- this.publicAxiosInstance,
8251
+ this.axiosInstance,
8129
8252
  this.defaultAccountId,
8130
8253
  this.logger,
8131
8254
  this.publicAxiosInstance
@@ -8195,7 +8318,7 @@ var AssinafyClient = class _AssinafyClient {
8195
8318
  if (baseUrl !== void 0) opts.baseUrl = baseUrl;
8196
8319
  if (webhookSecret !== void 0) opts.webhookSecret = webhookSecret;
8197
8320
  if (config.timeout !== void 0) opts.timeout = config.timeout;
8198
- const maxRetries = config.maxRetries ?? config.max_retries;
8321
+ const maxRetries = config.max_retries ?? config.maxRetries;
8199
8322
  if (maxRetries !== void 0) opts.maxRetries = maxRetries;
8200
8323
  if (config.logger !== void 0) opts.logger = config.logger;
8201
8324
  return new _AssinafyClient(opts);
@@ -124,15 +124,17 @@ ordinary OAuth applications use the two SDK methods listed below.
124
124
 
125
125
  ## Signing and public flows — 17/17
126
126
 
127
- All methods in this section use the auth-free transport. Most signer operations
128
- authenticate with the `signer-access-code` query parameter required by the
129
- OpenAPI security scheme. The artifact download is explicitly public and accepts
127
+ All access-code methods in this section use the auth-free transport and reject
128
+ a missing or blank code; they authenticate with the `signer-access-code` query
129
+ parameter required by the OpenAPI security scheme. The signer document list and
130
+ search also accept workspace credentials; only the explicit `listAsWorkspace` /
131
+ `searchAsWorkspace` methods send them, and never with an access code. The artifact download is explicitly public and accepts
130
132
  an optional fourth access-code argument only for legacy compatibility.
131
133
 
132
134
  | Method | Path | SDK method | Status |
133
135
  | --- | --- | --- | --- |
134
136
  | `GET` | `/v1/public/documents/{documentId}` | `client.documents.getPublic(documentId)` | Covered |
135
- | `PUT` | `/v1/public/documents/{documentId}/send-token` | `client.documents.sendToken(documentId, email)` | Covered |
137
+ | `PUT` | `/v1/public/documents/{documentId}/send-token` | `client.documents.sendToken(documentId, recipient, channel?)` | Covered |
136
138
  | `GET` | `/v1/signers/self` | `client.signerDocuments.self(accessCode)` | Covered |
137
139
  | `GET` | `/v1/signers/{signerId}/document` | `client.signerDocuments.getCurrent(signerId, accessCode)` | Covered |
138
140
  | `GET` | `/v1/sign` | `client.signerDocuments.getAssignment(accessCode, hasAcceptedTerms?)` | Covered |
@@ -145,8 +147,8 @@ an optional fourth access-code argument only for legacy compatibility.
145
147
  | `PUT` | `/v1/signers/accept-terms` | `client.signerDocuments.acceptTerms(accessCode)` | Covered |
146
148
  | `POST` | `/v1/signature` | `client.signerDocuments.uploadSignature(accessCode, image, options?)` | Covered |
147
149
  | `GET` | `/v1/signature/{signatureType}` | `client.signerDocuments.downloadSignature(accessCode, signatureType)` | Covered |
148
- | `GET` | `/v1/signers/{signerId}/documents` | `client.signerDocuments.list(signerId, accessCode, params?)` | Covered |
149
- | `GET` | `/v1/signers/{signerId}/documents/search` | `client.signerDocuments.search(signerId, accessCode, search)` | Covered |
150
+ | `GET` | `/v1/signers/{signerId}/documents` | `client.signerDocuments.list(signerId, accessCode, params?)` / `client.signerDocuments.listAsWorkspace(signerId, params?)` | Covered |
151
+ | `GET` | `/v1/signers/{signerId}/documents/search` | `client.signerDocuments.search(signerId, accessCode, search)` / `client.signerDocuments.searchAsWorkspace(signerId, search?)` | Covered |
150
152
  | `GET` | `/v1/signers/{signerId}/documents/{documentId}/download/{artifactName}` | `client.signerDocuments.download(signerId, documentId, artifactName)` | Covered |
151
153
 
152
154
  ## Tags — 4/4
@@ -179,7 +181,7 @@ Five additional routes are documented separately under
179
181
  | `POST` | `/v1/users/self/mfa/totp` | `client.users.startTotpEnrollment(label?)` | Covered |
180
182
  | `PUT` | `/v1/users/self/mfa/totp/confirm` | `client.users.confirmTotpEnrollment(payload)` | Covered |
181
183
  | `POST` | `/v1/users/self/mfa/recovery-codes` | `client.users.regenerateRecoveryCodes(proof)` | Covered |
182
- | `DELETE` | `/v1/users/self/mfa/{customId}` | `client.users.deleteMfaMethod(customId, proof)` | Covered |
184
+ | `DELETE` | `/v1/users/self/mfa/{customId}` | `client.users.deleteMfaMethod(methodId, proof)` | Covered |
183
185
 
184
186
  ## Webhooks — 13/13
185
187
 
@@ -194,30 +194,20 @@ and returns the JPEG bytes as a `Buffer`.
194
194
 
195
195
  ## Public send-token request
196
196
 
197
- The official operation sends an email body:
197
+ The operation requires both `channel` and `recipient`; `email` is the only
198
+ channel, and the response `data` is `{ document, channel, recipient }`:
198
199
 
199
200
  ```http
200
201
  PUT /v1/public/documents/{documentId}/send-token
201
202
  Content-Type: application/json
202
203
 
203
- { "email": "signer@example.com" }
204
+ { "channel": "email", "recipient": "signer@example.com" }
204
205
  ```
205
206
 
206
207
  ```ts
207
- await client.documents.sendToken(documentId, 'signer@example.com');
208
+ const { recipient } = await client.documents.sendToken(documentId, 'signer@example.com');
208
209
  ```
209
210
 
210
- Older environments can require `{ recipient, channel }`. The explicit
211
- three-argument overload sends that shape:
212
-
213
- ```ts
214
- await client.documents.sendToken(documentId, '+5511999990000', 'whatsapp');
215
- ```
216
-
217
- For a two-argument call, the SDK starts with `{ email }` and retries the older
218
- email shape only when the validation response names `recipient` or `channel` as
219
- required. Other errors are returned unchanged.
220
-
221
211
  ## Document tags
222
212
 
223
213
  Replace and attach requests require existing tag IDs:
@@ -344,9 +334,9 @@ Document upload accepts a PDF of at most 25 MB and 2,000 pages. The multipart
344
334
  schema documents the file; the SDK's optional `metadata` JSON part is retained
345
335
  for deployments that accept application-owned opaque metadata.
346
336
 
347
- The reset-expiration schema requires an ISO-8601 date-time string. The SDK also
348
- accepts `null` for older integrations that clear an expiration this way. Confirm
349
- support in the target deployment before sending `null`.
337
+ The reset-expiration schema requires the `expires_at` key itself: send an
338
+ ISO-8601 date-time string, or `null` to remove the expiration. The SDK's
339
+ `resetExpiration` always sends the key and accepts `null` for clearing.
350
340
 
351
341
  ## Resend-cost response variants
352
342
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/sdk",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "packageManager": "bun@1.4.0",
5
5
  "description": "TypeScript SDK for Assinafy API - Digital signature platform",
6
6
  "type": "commonjs",
@@ -63,7 +63,7 @@
63
63
  "bugs": {
64
64
  "url": "https://github.com/assinafy/typescript-sdk/issues"
65
65
  },
66
- "homepage": "https://github.com/assinafy/typescript-sdk/#readme",
66
+ "homepage": "https://www.assinafy.com.br",
67
67
  "devDependencies": {
68
68
  "@arethetypeswrong/cli": "^0.18.5",
69
69
  "@eslint/js": "^10.0.1",