@assinafy/sdk 2.4.2 → 2.5.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/CHANGELOG.md +82 -20
- package/README.en.md +72 -14
- package/README.md +15 -10
- package/SECURITY.md +6 -5
- package/dist/index.d.mts +160 -38
- package/dist/index.d.ts +160 -38
- package/dist/index.js +167 -62
- package/dist/index.mjs +167 -62
- package/docs/API_COVERAGE.md +11 -0
- package/docs/COMPATIBILITY.md +4 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -361,6 +361,7 @@ interface IAssignment {
|
|
|
361
361
|
sender_email?: string;
|
|
362
362
|
method: AssignmentMethod;
|
|
363
363
|
expires_at?: string | null;
|
|
364
|
+
/** Compatibility extension; absent from the OpenAPI Assignment schema. */
|
|
364
365
|
expiration?: string;
|
|
365
366
|
message?: string | null;
|
|
366
367
|
signers: IAssignmentSigner[];
|
|
@@ -961,6 +962,11 @@ interface IPublicDocumentInfo extends Partial<Omit<IDocumentDetailsResponse, 'id
|
|
|
961
962
|
interface IDocumentVerification {
|
|
962
963
|
hash: string;
|
|
963
964
|
id: string | null;
|
|
965
|
+
/**
|
|
966
|
+
* Agreement code printed on the document certificate; `null` when the hash
|
|
967
|
+
* does not verify. Absent from deployments that predate the field.
|
|
968
|
+
*/
|
|
969
|
+
agreement_code?: string | null;
|
|
964
970
|
status: DocumentStatus | AnyString | null;
|
|
965
971
|
page_count: string | null;
|
|
966
972
|
signer_count: string | null;
|
|
@@ -1094,6 +1100,7 @@ interface IWhatsAppNotification {
|
|
|
1094
1100
|
sent_at: number;
|
|
1095
1101
|
header: string;
|
|
1096
1102
|
body: string;
|
|
1103
|
+
/** Compatibility extension: the spec documents only `text`; `url` is retained for deployments that send link buttons. */
|
|
1097
1104
|
buttons: Array<{
|
|
1098
1105
|
text: string;
|
|
1099
1106
|
url?: string;
|
|
@@ -1599,8 +1606,7 @@ declare class DocumentResource extends BaseResource {
|
|
|
1599
1606
|
* "updated_at": "2026-07-19T17:24:46Z"
|
|
1600
1607
|
* }
|
|
1601
1608
|
* ```
|
|
1602
|
-
* @throws {ValidationError} If `documentId` is missing
|
|
1603
|
-
* not one of the five documented artifact names.
|
|
1609
|
+
* @throws {ValidationError} If `documentId` is missing.
|
|
1604
1610
|
* @throws {ApiError} `404` if the document does not exist.
|
|
1605
1611
|
*
|
|
1606
1612
|
* @example
|
|
@@ -2006,6 +2012,7 @@ declare class DocumentResource extends BaseResource {
|
|
|
2006
2012
|
* {
|
|
2007
2013
|
* "hash": "FE32EDDADE7CBDDCBB934E7402047450B0E59C02",
|
|
2008
2014
|
* "id": "63ddb172402799bfc991d10d",
|
|
2015
|
+
* "agreement_code": "550E8400-E29B-41D4-A716-446655440000", // printed on the certificate
|
|
2009
2016
|
* "status": "certificated",
|
|
2010
2017
|
* "page_count": "1",
|
|
2011
2018
|
* "signer_count": "1",
|
|
@@ -2127,7 +2134,8 @@ declare class DocumentResource extends BaseResource {
|
|
|
2127
2134
|
sendToken(documentId: string, email: string): Promise<void>;
|
|
2128
2135
|
sendToken(documentId: string, recipient: string, channel: SendTokenChannel): Promise<void>;
|
|
2129
2136
|
/**
|
|
2130
|
-
* Quick boolean check: has every signer
|
|
2137
|
+
* Quick boolean check (`GET /documents/{documentId}`): has every signer
|
|
2138
|
+
* completed their assignment?
|
|
2131
2139
|
*
|
|
2132
2140
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2133
2141
|
* /documents/{documentId}`). Returns `true` when the document status is
|
|
@@ -2149,7 +2157,8 @@ declare class DocumentResource extends BaseResource {
|
|
|
2149
2157
|
*/
|
|
2150
2158
|
isFullySigned(documentId: string): Promise<boolean>;
|
|
2151
2159
|
/**
|
|
2152
|
-
* Summarise signing progress for UI display
|
|
2160
|
+
* Summarise signing progress for UI display
|
|
2161
|
+
* (`GET /documents/{documentId}`).
|
|
2153
2162
|
*
|
|
2154
2163
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2155
2164
|
* /documents/{documentId}`). `total` and `signed` come from the assignment
|
|
@@ -2916,11 +2925,11 @@ declare class AssignmentResource extends BaseResource {
|
|
|
2916
2925
|
* @param documentId - The document the assignment would be created on.
|
|
2917
2926
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
2918
2927
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
2919
|
-
* of this request schema.
|
|
2920
|
-
* `InsufficientDocuments`, or `InsufficientCredits`.
|
|
2928
|
+
* of this request schema.
|
|
2921
2929
|
* @returns an {@link ICostEstimate} with `total_credits`, balances, a
|
|
2922
|
-
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
2923
|
-
*
|
|
2930
|
+
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
2931
|
+
* `blocking_reason` may be `PendingPayment`, `InsufficientDocuments`, or
|
|
2932
|
+
* `InsufficientCredits`. Response shape:
|
|
2924
2933
|
* ```jsonc
|
|
2925
2934
|
* {
|
|
2926
2935
|
* "documents": 1,
|
|
@@ -3854,7 +3863,7 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3854
3863
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
3855
3864
|
* "user": {
|
|
3856
3865
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
3857
|
-
* "name": "
|
|
3866
|
+
* "name": "Empresa Exemplo",
|
|
3858
3867
|
* "email": "user@example.com",
|
|
3859
3868
|
* "telephone": null,
|
|
3860
3869
|
* "government_id": "",
|
|
@@ -3866,7 +3875,7 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3866
3875
|
* "accounts": [
|
|
3867
3876
|
* {
|
|
3868
3877
|
* "id": "acc_example",
|
|
3869
|
-
* "name": "
|
|
3878
|
+
* "name": "Empresa Exemplo",
|
|
3870
3879
|
* "roles": ["Owner"],
|
|
3871
3880
|
* "is_delete_allowed": true,
|
|
3872
3881
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -3905,7 +3914,7 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3905
3914
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
3906
3915
|
* "user": {
|
|
3907
3916
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
3908
|
-
* "name": "
|
|
3917
|
+
* "name": "Empresa Exemplo",
|
|
3909
3918
|
* "email": "user@example.com",
|
|
3910
3919
|
* "telephone": null,
|
|
3911
3920
|
* "government_id": "",
|
|
@@ -3917,7 +3926,7 @@ declare class AuthenticationResource extends BaseResource {
|
|
|
3917
3926
|
* "accounts": [
|
|
3918
3927
|
* {
|
|
3919
3928
|
* "id": "acc_example",
|
|
3920
|
-
* "name": "
|
|
3929
|
+
* "name": "Empresa Exemplo",
|
|
3921
3930
|
* "roles": ["Owner"],
|
|
3922
3931
|
* "is_delete_allowed": true,
|
|
3923
3932
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4198,8 +4207,9 @@ type TokenEndpointAuthOptions = {
|
|
|
4198
4207
|
* disconnects.
|
|
4199
4208
|
*
|
|
4200
4209
|
* Two facts that cause most integration bugs: a token works for exactly one
|
|
4201
|
-
* workspace (any other answers `403`), and
|
|
4202
|
-
*
|
|
4210
|
+
* workspace (any other answers `403`), and every refresh returns a new refresh
|
|
4211
|
+
* token that retires the old one. Each new refresh token is valid for a fresh
|
|
4212
|
+
* 30 days, so a connection only expires after 30 days without a refresh.
|
|
4203
4213
|
*
|
|
4204
4214
|
* @example
|
|
4205
4215
|
* ```ts
|
|
@@ -4398,8 +4408,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4398
4408
|
*
|
|
4399
4409
|
* The `iss` check is strict because the authorization server advertises
|
|
4400
4410
|
* RFC 9207 support and always sends the parameter: a missing `iss` is
|
|
4401
|
-
* treated exactly like a wrong one
|
|
4402
|
-
* something between the browser and your handler strips query parameters.
|
|
4411
|
+
* treated exactly like a wrong one, on success and error responses alike.
|
|
4403
4412
|
*
|
|
4404
4413
|
* This performs no network I/O.
|
|
4405
4414
|
*
|
|
@@ -4407,7 +4416,9 @@ declare class OAuthResource extends BaseResource {
|
|
|
4407
4416
|
* `req.query` record, a `URLSearchParams`, a `URL`, a full callback URL
|
|
4408
4417
|
* string, or a bare `a=b&c=d` query string.
|
|
4409
4418
|
* @param expected - The stored {@link IOAuthAuthorizationRequest} (or any
|
|
4410
|
-
* object carrying its `state` and `issuer`).
|
|
4419
|
+
* object carrying its `state` and `issuer`). Without `issuer`, `iss` must
|
|
4420
|
+
* equal `https://auth.assinafy.com.br`; pass the stored one for any other
|
|
4421
|
+
* authorization server, such as the sandbox's.
|
|
4411
4422
|
* @returns The validated response:
|
|
4412
4423
|
* ```jsonc
|
|
4413
4424
|
* {
|
|
@@ -4513,7 +4524,9 @@ declare class OAuthResource extends BaseResource {
|
|
|
4513
4524
|
* and re-read your stored token instead of retrying blindly, and never run
|
|
4514
4525
|
* two refreshes concurrently for one connection.
|
|
4515
4526
|
*
|
|
4516
|
-
*
|
|
4527
|
+
* Each returned refresh token is valid for a fresh 30 days, so a connection
|
|
4528
|
+
* only expires if it goes 30 days without a refresh; after that the user
|
|
4529
|
+
* has to reconnect.
|
|
4517
4530
|
*
|
|
4518
4531
|
* @param options - Refresh options.
|
|
4519
4532
|
* @param options.refreshToken - The current refresh token.
|
|
@@ -4521,7 +4534,8 @@ declare class OAuthResource extends BaseResource {
|
|
|
4521
4534
|
* @param options.clientSecret - The `client_secret`, for confidential
|
|
4522
4535
|
* applications only.
|
|
4523
4536
|
* @param options.resource - RFC 8707 resource indicator. Defaults to this
|
|
4524
|
-
* API's origin; pass `null` to omit it.
|
|
4537
|
+
* API's origin; pass `null` to omit it. A refresh may repeat the value the
|
|
4538
|
+
* connection was authorized with but never change it (`invalid_target`).
|
|
4525
4539
|
* @returns A fresh token set, identical in shape to
|
|
4526
4540
|
* {@link OAuthResource.exchangeCode}:
|
|
4527
4541
|
* ```jsonc
|
|
@@ -4571,14 +4585,9 @@ declare class OAuthResource extends BaseResource {
|
|
|
4571
4585
|
* @param options.tokenTypeHint - Optional `access_token` or
|
|
4572
4586
|
* `refresh_token` hint that lets the server skip a lookup.
|
|
4573
4587
|
* @returns Nothing; resolves once the API acknowledges the request.
|
|
4574
|
-
* Request body:
|
|
4575
|
-
* ```
|
|
4576
|
-
*
|
|
4577
|
-
* "token": "def50200f1e2…",
|
|
4578
|
-
* "token_type_hint": "refresh_token",
|
|
4579
|
-
* "client_id": "cli_1a2b3c",
|
|
4580
|
-
* "client_secret": "…"
|
|
4581
|
-
* }
|
|
4588
|
+
* Request body (`application/x-www-form-urlencoded`):
|
|
4589
|
+
* ```text
|
|
4590
|
+
* token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
|
|
4582
4591
|
* ```
|
|
4583
4592
|
* @throws {ValidationError} If `token` or `clientId` is missing, or
|
|
4584
4593
|
* `tokenTypeHint` is not one of the two documented values.
|
|
@@ -4631,7 +4640,12 @@ declare class OAuthResource extends BaseResource {
|
|
|
4631
4640
|
* ```
|
|
4632
4641
|
*/
|
|
4633
4642
|
getUserInfo(accessToken?: string): Promise<IOAuthUserInfo>;
|
|
4634
|
-
/**
|
|
4643
|
+
/**
|
|
4644
|
+
* POST the token endpoint once and assert the response carries a token.
|
|
4645
|
+
*
|
|
4646
|
+
* Never retried: the code is single-use, and replaying a refresh token the
|
|
4647
|
+
* server may already have rotated ends the whole connection.
|
|
4648
|
+
*/
|
|
4635
4649
|
private requestToken;
|
|
4636
4650
|
/** `client_secret_post` credentials, omitting the secret for public clients. */
|
|
4637
4651
|
private clientAuth;
|
|
@@ -4974,8 +4988,7 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
4974
4988
|
* "updated_at": "2026-07-19T14:56:56Z"
|
|
4975
4989
|
* }
|
|
4976
4990
|
* ```
|
|
4977
|
-
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing
|
|
4978
|
-
* or a supplied `search` value is not a string.
|
|
4991
|
+
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
4979
4992
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
4980
4993
|
*
|
|
4981
4994
|
* @example
|
|
@@ -5045,7 +5058,29 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5045
5058
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
5046
5059
|
* @param search - Free-text term matched against the document name.
|
|
5047
5060
|
* @returns Matching documents for that signer, in the compact
|
|
5048
|
-
* {@link IDocumentListItem} shape, with pagination in `meta
|
|
5061
|
+
* {@link IDocumentListItem} shape, with pagination in `meta`:
|
|
5062
|
+
* ```jsonc
|
|
5063
|
+
* {
|
|
5064
|
+
* "data": [
|
|
5065
|
+
* {
|
|
5066
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
5067
|
+
* "account_id": "acc_example",
|
|
5068
|
+
* "template_id": null,
|
|
5069
|
+
* "name": "Service agreement.pdf",
|
|
5070
|
+
* "status": "pending_signature",
|
|
5071
|
+
* "artifacts": { "original": "https://...", "thumbnail": "https://..." },
|
|
5072
|
+
* "is_closed": false,
|
|
5073
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
5074
|
+
* "decline_reason": null,
|
|
5075
|
+
* "declined_by": null,
|
|
5076
|
+
* "tags": [],
|
|
5077
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
5078
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
5079
|
+
* }
|
|
5080
|
+
* ],
|
|
5081
|
+
* "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
|
|
5082
|
+
* }
|
|
5083
|
+
* ```
|
|
5049
5084
|
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
5050
5085
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
5051
5086
|
*
|
|
@@ -5263,7 +5298,17 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5263
5298
|
* @param payload - Any of the official `full_name`, `email`, or
|
|
5264
5299
|
* `government_id`, or `has_accepted_terms` fields. Fields left out are not
|
|
5265
5300
|
* sent.
|
|
5266
|
-
* @returns The confirmed signer in the full {@link ISigner} response shape
|
|
5301
|
+
* @returns The confirmed signer in the full {@link ISigner} response shape:
|
|
5302
|
+
* ```jsonc
|
|
5303
|
+
* {
|
|
5304
|
+
* "resource": "signer",
|
|
5305
|
+
* "id": "19e6b92e7895332ed9708535d8c",
|
|
5306
|
+
* "full_name": "Example Signer",
|
|
5307
|
+
* "email": "signer@example.com",
|
|
5308
|
+
* "whatsapp_phone_number": null,
|
|
5309
|
+
* "has_accepted_terms": true
|
|
5310
|
+
* }
|
|
5311
|
+
* ```
|
|
5267
5312
|
* @throws {ValidationError} If `documentId` or `signerAccessCode` is missing,
|
|
5268
5313
|
* or a supplied identity value is malformed.
|
|
5269
5314
|
* @throws {ApiError} If the access code is invalid/expired or a value fails
|
|
@@ -5368,7 +5413,48 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
5368
5413
|
* @returns The document to sign, including its `assignment` (the
|
|
5369
5414
|
* {@link IAssignment} shape: `signers`, `items`, `summary`, `signing_urls`)
|
|
5370
5415
|
* from which the `itemId` / `fieldId` / `pageId` values for
|
|
5371
|
-
* {@link SignerDocumentsResource.sign} are read
|
|
5416
|
+
* {@link SignerDocumentsResource.sign} are read:
|
|
5417
|
+
* ```jsonc
|
|
5418
|
+
* {
|
|
5419
|
+
* "resource": "document",
|
|
5420
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
5421
|
+
* "account_id": "acc_example",
|
|
5422
|
+
* "template_id": null,
|
|
5423
|
+
* "name": "Service agreement.pdf",
|
|
5424
|
+
* "status": "pending_signature",
|
|
5425
|
+
* "artifacts": {
|
|
5426
|
+
* "original": "https://api.assinafy.com.br/v1/documents/103acccd.../download/original",
|
|
5427
|
+
* "thumbnail": "https://api.assinafy.com.br/v1/documents/103acccd.../thumbnail"
|
|
5428
|
+
* },
|
|
5429
|
+
* "is_closed": false,
|
|
5430
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
5431
|
+
* "decline_reason": null,
|
|
5432
|
+
* "declined_by": null,
|
|
5433
|
+
* "tags": [],
|
|
5434
|
+
* "assignment": {
|
|
5435
|
+
* "id": "1032c55c58bb00a8dc35db916751",
|
|
5436
|
+
* "method": "virtual",
|
|
5437
|
+
* "sender_email": "sender@example.com",
|
|
5438
|
+
* "expires_at": null,
|
|
5439
|
+
* "signers": [
|
|
5440
|
+
* { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
|
|
5441
|
+
* "full_name": "Example Signer", "notified": true, "completed": false }
|
|
5442
|
+
* ],
|
|
5443
|
+
* "items": [
|
|
5444
|
+
* { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
|
|
5445
|
+
* "download_url": "https://..." }, "signer": { "id": "19e6b92e..." },
|
|
5446
|
+
* "field": { "id": "field-1", "type": "signature" }, "value": null, "completed": false }
|
|
5447
|
+
* ],
|
|
5448
|
+
* "summary": { "signer_count": 1, "completed_count": 0, "signers": [] }
|
|
5449
|
+
* },
|
|
5450
|
+
* "pages": [
|
|
5451
|
+
* { "id": "103acccd5c73...", "number": 1, "height": 1651, "width": 1275,
|
|
5452
|
+
* "download_url": "https://api.assinafy.com.br/v1/documents/103acccd.../pages/103acccd5c73.../download" }
|
|
5453
|
+
* ],
|
|
5454
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
5455
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
5456
|
+
* }
|
|
5457
|
+
* ```
|
|
5372
5458
|
* @throws {ValidationError} If `signerAccessCode` is missing.
|
|
5373
5459
|
* @throws {ApiError} `400` when DigitalCertificate identity/terms are not
|
|
5374
5460
|
* confirmed; `401`/`403` if the access code is invalid or expired; `409`
|
|
@@ -5559,8 +5645,20 @@ declare class UserResource extends BaseResource {
|
|
|
5559
5645
|
* ```json
|
|
5560
5646
|
* { "DocumentCompleted": true, "SignerDeclined": false }
|
|
5561
5647
|
* ```
|
|
5562
|
-
* @returns The complete updated
|
|
5563
|
-
*
|
|
5648
|
+
* @returns The complete updated nine-key preference map:
|
|
5649
|
+
* ```json
|
|
5650
|
+
* {
|
|
5651
|
+
* "DocumentCompleted": true,
|
|
5652
|
+
* "SignerDeclined": false,
|
|
5653
|
+
* "DocumentCancelled": true,
|
|
5654
|
+
* "DocumentAboutToExpire": true,
|
|
5655
|
+
* "DocumentExpired": false,
|
|
5656
|
+
* "DocumentExpirationReset": true,
|
|
5657
|
+
* "DocumentProcessingFailed": true,
|
|
5658
|
+
* "TemplateProcessingFailed": true,
|
|
5659
|
+
* "SignerWhatsappFailed": true
|
|
5660
|
+
* }
|
|
5661
|
+
* ```
|
|
5564
5662
|
* @throws {ValidationError} Before requesting when the map is empty, has an
|
|
5565
5663
|
* unknown key, or contains a non-boolean value.
|
|
5566
5664
|
* @throws {ApiError} `400` if the API rejects the map, `401` for invalid
|
|
@@ -5867,7 +5965,10 @@ declare class AssinafyClient {
|
|
|
5867
5965
|
* the upload is empty / non-PDF / larger than 25 MB, or `waitForReady` is
|
|
5868
5966
|
* enabled and processing exceeds the {@link DocumentResource.waitUntilReady}
|
|
5869
5967
|
* timeout.
|
|
5870
|
-
* @throws {ApiError} If any underlying API call is rejected
|
|
5968
|
+
* @throws {ApiError} If any underlying API call is rejected — see the
|
|
5969
|
+
* `@throws` of {@link DocumentResource.upload}, {@link SignerResource.create},
|
|
5970
|
+
* {@link AssignmentResource.create}, and
|
|
5971
|
+
* {@link DocumentResource.waitUntilReady} for the per-step statuses.
|
|
5871
5972
|
*
|
|
5872
5973
|
* @example
|
|
5873
5974
|
* ```ts
|
|
@@ -5954,7 +6055,16 @@ interface IAuthenticateChallenge {
|
|
|
5954
6055
|
*
|
|
5955
6056
|
* @param value - Raw header value, or `undefined` when absent.
|
|
5956
6057
|
* @returns The parsed challenge, or `undefined` when there is no header or it
|
|
5957
|
-
* carries no scheme.
|
|
6058
|
+
* carries no scheme. Malformed input never throws; it yields `undefined` or a
|
|
6059
|
+
* scheme-only challenge.
|
|
6060
|
+
*
|
|
6061
|
+
* @example
|
|
6062
|
+
* ```ts
|
|
6063
|
+
* const challenge = parseWwwAuthenticate(
|
|
6064
|
+
* 'Bearer error="insufficient_scope", scope="documents:read"',
|
|
6065
|
+
* );
|
|
6066
|
+
* // → { scheme: 'Bearer', error: 'insufficient_scope', scope: 'documents:read' }
|
|
6067
|
+
* ```
|
|
5958
6068
|
*/
|
|
5959
6069
|
declare function parseWwwAuthenticate(value: string | undefined): IAuthenticateChallenge | undefined;
|
|
5960
6070
|
|
|
@@ -6022,7 +6132,9 @@ declare class ApiError extends AssinafyError {
|
|
|
6022
6132
|
* ones with no structured body to explain them. Anything else falls back to
|
|
6023
6133
|
* the stable message.
|
|
6024
6134
|
* @returns An `ApiError` retaining the original response body in
|
|
6025
|
-
* {@link ApiError.responseData}
|
|
6135
|
+
* {@link ApiError.responseData}. A JSON `message` is used verbatim; only an
|
|
6136
|
+
* unstructured text body is whitespace-collapsed and truncated for
|
|
6137
|
+
* legibility.
|
|
6026
6138
|
*
|
|
6027
6139
|
* @example
|
|
6028
6140
|
* ```ts
|
|
@@ -6082,6 +6194,16 @@ declare class OAuthError extends ApiError {
|
|
|
6082
6194
|
* @param error - Any thrown value.
|
|
6083
6195
|
* @returns An `OAuthError` when the body carries a non-empty string
|
|
6084
6196
|
* `error`, else the original value.
|
|
6197
|
+
*
|
|
6198
|
+
* @example
|
|
6199
|
+
* ```ts
|
|
6200
|
+
* const apiError = ApiError.fromResponse(400, {
|
|
6201
|
+
* error: 'invalid_grant',
|
|
6202
|
+
* error_description: 'The provided authorization grant is invalid.',
|
|
6203
|
+
* });
|
|
6204
|
+
* const upgraded = OAuthError.upgrade(apiError);
|
|
6205
|
+
* // upgraded instanceof OAuthError → true, .error → 'invalid_grant'
|
|
6206
|
+
* ```
|
|
6085
6207
|
*/
|
|
6086
6208
|
static upgrade(error: unknown): unknown;
|
|
6087
6209
|
}
|