@assinafy/cli 2.0.3 → 2.1.2
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/.env.example +54 -0
- package/CONTRIBUTING.md +29 -0
- package/README.en.md +561 -0
- package/README.md +309 -205
- package/SECURITY.md +10 -0
- package/dist/api.cjs +294 -44
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +291 -43
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +637 -61
- package/dist/types/api/client.d.ts +7 -0
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api/errors.d.ts +42 -1
- package/dist/types/api/errors.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/resources/oauth.d.ts +20 -0
- package/dist/types/api/resources/oauth.d.ts.map +1 -0
- package/dist/types/api/resources/signers.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +90 -5
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +1 -1
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/README.md +4 -2
- package/docs/api-operations.json +33 -1
- package/docs/api-reference.md +246 -12
- package/docs/migration-v2.md +6 -2
- package/docs/oauth-guide.md +347 -0
- package/docs/oauth.md +162 -0
- package/docs/releasing.md +12 -7
- package/docs/sdk-reference.md +52 -17
- package/install.ps1 +9 -2
- package/install.sh +5 -5
- package/package.json +5 -2
package/docs/api-reference.md
CHANGED
|
@@ -6,8 +6,8 @@ The renderer reuses a generic 400 envelope for several non-400 errors; top-level
|
|
|
6
6
|
|
|
7
7
|
- OpenAPI: 3.0.0
|
|
8
8
|
- API document version: 1.0.0
|
|
9
|
-
- Operations:
|
|
10
|
-
- Contract SHA-256: `
|
|
9
|
+
- Operations: 93
|
|
10
|
+
- Contract SHA-256: `6b55ce24462cd0f9393061a075f2c296fbe742fae493c9ba81c7def402618456`
|
|
11
11
|
|
|
12
12
|
## Accounts
|
|
13
13
|
|
|
@@ -473,6 +473,8 @@ Remove the account logo image.
|
|
|
473
473
|
|
|
474
474
|
List the workspace accounts the authenticated user belongs to.
|
|
475
475
|
|
|
476
|
+
Called with an OAuth application token, this returns exactly one workspace: the one the user chose when they authorized the application. Use its `id` as the `{accountId}` segment of every other endpoint — a token is bound to a single workspace, and any request naming a different one is refused. This endpoint needs no particular scope.
|
|
477
|
+
|
|
476
478
|
**Authentication:** Bearer access token (`Authorization: Bearer ...`) or API key (`X-Api-Key` header).
|
|
477
479
|
|
|
478
480
|
#### Responses
|
|
@@ -2927,7 +2929,7 @@ Per-unit costs (in credits) used to build the estimate:
|
|
|
2927
2929
|
| WhatsApp notification | 0.45 credits |
|
|
2928
2930
|
| Digital certificate signature (per signer) | 2 credits |
|
|
2929
2931
|
|
|
2930
|
-
A `DigitalCertificate` signer adds the digital-certificate signature cost **on top of** its notification cost; it appears in the `breakdown` under the `SignatureDigitalCertificate` code.
|
|
2932
|
+
Verification methods are not priced separately — every line in the `breakdown` is a notification or a signature. A `Whatsapp`-verified signer therefore shows up as a WhatsApp notification, because that channel is mandatory for that verification method. A `DigitalCertificate` signer adds the digital-certificate signature cost **on top of** its notification cost; it appears in the `breakdown` under the `SignatureDigitalCertificate` code.
|
|
2931
2933
|
|
|
2932
2934
|
**Authentication:** Bearer access token (`Authorization: Bearer ...`) or API key (`X-Api-Key` header).
|
|
2933
2935
|
|
|
@@ -4700,6 +4702,238 @@ Returns the profile of the user owning the access token.
|
|
|
4700
4702
|
}
|
|
4701
4703
|
```
|
|
4702
4704
|
|
|
4705
|
+
## OAuth
|
|
4706
|
+
|
|
4707
|
+
### Exchange a code or refresh token for an access token
|
|
4708
|
+
|
|
4709
|
+
`POST /v1/oauth/token`
|
|
4710
|
+
|
|
4711
|
+
Implements the RFC 6749 §5.1/§5.2 token-endpoint body contract in
|
|
4712
|
+
* both directions: a successful exchange returns a flat JSON object with
|
|
4713
|
+
* `access_token` at the top level, and a failure returns a flat
|
|
4714
|
+
* `{error, error_description}` object — neither is wrapped in this API's
|
|
4715
|
+
* usual response envelope, since no standard OAuth client library (or MCP
|
|
4716
|
+
* connector) would find `access_token` or `error` inside a `data` key.
|
|
4717
|
+
|
|
4718
|
+
**Authentication:** none (public endpoint).
|
|
4719
|
+
|
|
4720
|
+
#### Request Body (required)
|
|
4721
|
+
|
|
4722
|
+
Fields (`application/json`):
|
|
4723
|
+
|
|
4724
|
+
- `grant_type` (string, required)
|
|
4725
|
+
- `code` (string)
|
|
4726
|
+
- `redirect_uri` (string)
|
|
4727
|
+
- `code_verifier` (string) — RFC 7636: 43-128 characters from [A-Za-z0-9-._~]. Shorter values are rejected with `invalid_grant`.
|
|
4728
|
+
- `refresh_token` (string)
|
|
4729
|
+
- `client_id` (string, required)
|
|
4730
|
+
- `client_secret` (string) — Confidential clients only. Public clients authenticate with PKCE and are never issued a secret.
|
|
4731
|
+
- `resource` (string) — RFC 8707 resource indicator. Optional; when present it must be the `resource` value published by /.well-known/oauth-protected-resource and must match the one sent to /authorize, otherwise `invalid_target`.
|
|
4732
|
+
|
|
4733
|
+
Example:
|
|
4734
|
+
|
|
4735
|
+
```json
|
|
4736
|
+
{
|
|
4737
|
+
"grant_type": "authorization_code",
|
|
4738
|
+
"code": "string",
|
|
4739
|
+
"redirect_uri": "https://example.com/example-url-11",
|
|
4740
|
+
"code_verifier": "string",
|
|
4741
|
+
"refresh_token": "example_secret",
|
|
4742
|
+
"client_id": "example_id_5",
|
|
4743
|
+
"client_secret": "example_secret",
|
|
4744
|
+
"resource": "string"
|
|
4745
|
+
}
|
|
4746
|
+
```
|
|
4747
|
+
|
|
4748
|
+
#### Responses
|
|
4749
|
+
|
|
4750
|
+
##### 200 — The token response
|
|
4751
|
+
|
|
4752
|
+
```json
|
|
4753
|
+
{
|
|
4754
|
+
"access_token": "example_credential",
|
|
4755
|
+
"token_type": "Bearer",
|
|
4756
|
+
"expires_in": 3600,
|
|
4757
|
+
"refresh_token": "example_secret",
|
|
4758
|
+
"scope": "documents:read",
|
|
4759
|
+
"id_token": "example_secret"
|
|
4760
|
+
}
|
|
4761
|
+
```
|
|
4762
|
+
|
|
4763
|
+
##### 400 — `invalid_grant` (bad, expired, replayed, or wrong-client authorization code; a `code_verifier` outside the RFC 7636 grammar of 43-128 unreserved characters; redirect_uri mismatch; a refresh token whose authorization no longer includes `offline_access`), `invalid_target` (a `resource` this server does not issue tokens for, or one disagreeing with the authorized value), or `unsupported_grant_type`
|
|
4764
|
+
|
|
4765
|
+
```json
|
|
4766
|
+
{
|
|
4767
|
+
"error": "invalid_grant",
|
|
4768
|
+
"error_description": "string"
|
|
4769
|
+
}
|
|
4770
|
+
```
|
|
4771
|
+
|
|
4772
|
+
##### 401 — `invalid_client` — unknown/disabled client or failed client authentication. The description never reveals whether client_id exists.
|
|
4773
|
+
|
|
4774
|
+
```json
|
|
4775
|
+
{
|
|
4776
|
+
"error": "invalid_client",
|
|
4777
|
+
"error_description": "Client authentication failed."
|
|
4778
|
+
}
|
|
4779
|
+
```
|
|
4780
|
+
|
|
4781
|
+
##### 500 — Unexpected server error.
|
|
4782
|
+
|
|
4783
|
+
```json
|
|
4784
|
+
{
|
|
4785
|
+
"status": 500,
|
|
4786
|
+
"message": "Bad request.",
|
|
4787
|
+
"data": null
|
|
4788
|
+
}
|
|
4789
|
+
```
|
|
4790
|
+
|
|
4791
|
+
### Revoke a token
|
|
4792
|
+
|
|
4793
|
+
`POST /v1/oauth/revoke`
|
|
4794
|
+
|
|
4795
|
+
Revokes an access or refresh token. Every token outcome always returns 200 — including a token that does not exist, is already revoked, or is malformed — so the endpoint can never be used to probe whether a token exists. The one exception is failed client authentication, which returns 401.
|
|
4796
|
+
|
|
4797
|
+
**Authentication:** none (public endpoint).
|
|
4798
|
+
|
|
4799
|
+
#### Request Body (required)
|
|
4800
|
+
|
|
4801
|
+
Fields (`application/json`):
|
|
4802
|
+
|
|
4803
|
+
- `token` (string, required)
|
|
4804
|
+
- `token_type_hint` (string)
|
|
4805
|
+
- `client_id` (string, required)
|
|
4806
|
+
- `client_secret` (string)
|
|
4807
|
+
|
|
4808
|
+
Example:
|
|
4809
|
+
|
|
4810
|
+
```json
|
|
4811
|
+
{
|
|
4812
|
+
"token": "example_secret",
|
|
4813
|
+
"token_type_hint": "access_token",
|
|
4814
|
+
"client_id": "example_id_5",
|
|
4815
|
+
"client_secret": "example_secret"
|
|
4816
|
+
}
|
|
4817
|
+
```
|
|
4818
|
+
|
|
4819
|
+
#### Responses
|
|
4820
|
+
|
|
4821
|
+
##### 200 — Revoked
|
|
4822
|
+
|
|
4823
|
+
##### 401 — `invalid_client` — the only case that is not reported as success. Every token outcome (revoked, already revoked, unknown, malformed) always returns 200; only failed client authentication returns 401.
|
|
4824
|
+
|
|
4825
|
+
```json
|
|
4826
|
+
{
|
|
4827
|
+
"error": "invalid_client",
|
|
4828
|
+
"error_description": "Client authentication failed."
|
|
4829
|
+
}
|
|
4830
|
+
```
|
|
4831
|
+
|
|
4832
|
+
##### 500 — Unexpected server error.
|
|
4833
|
+
|
|
4834
|
+
```json
|
|
4835
|
+
{
|
|
4836
|
+
"status": 500,
|
|
4837
|
+
"message": "Bad request.",
|
|
4838
|
+
"data": null
|
|
4839
|
+
}
|
|
4840
|
+
```
|
|
4841
|
+
|
|
4842
|
+
### OpenID Connect userinfo
|
|
4843
|
+
|
|
4844
|
+
`GET /v1/oauth/userinfo`
|
|
4845
|
+
|
|
4846
|
+
Claims about the user who authorized this token. Requires the openid scope; name requires profile and email requires email. Per OIDC Core §5.3.2, the response is a flat JSON object of claims — never this API's usual `{status, data, message}` envelope.
|
|
4847
|
+
|
|
4848
|
+
**Authentication:** Bearer access token (`Authorization: Bearer ...`) or API key (`X-Api-Key` header).
|
|
4849
|
+
|
|
4850
|
+
#### Responses
|
|
4851
|
+
|
|
4852
|
+
##### 200 — The user's claims
|
|
4853
|
+
|
|
4854
|
+
```json
|
|
4855
|
+
{
|
|
4856
|
+
"sub": "example_id_29",
|
|
4857
|
+
"name": "Maria Silva",
|
|
4858
|
+
"email": "user9@example.com",
|
|
4859
|
+
"email_verified": true
|
|
4860
|
+
}
|
|
4861
|
+
```
|
|
4862
|
+
|
|
4863
|
+
##### 403 — Authenticated but not allowed to perform this action.
|
|
4864
|
+
|
|
4865
|
+
```json
|
|
4866
|
+
{
|
|
4867
|
+
"status": 403,
|
|
4868
|
+
"message": "Bad request.",
|
|
4869
|
+
"data": null
|
|
4870
|
+
}
|
|
4871
|
+
```
|
|
4872
|
+
|
|
4873
|
+
##### 401 — Missing or invalid credentials.
|
|
4874
|
+
|
|
4875
|
+
```json
|
|
4876
|
+
{
|
|
4877
|
+
"status": 401,
|
|
4878
|
+
"message": "Bad request.",
|
|
4879
|
+
"data": null
|
|
4880
|
+
}
|
|
4881
|
+
```
|
|
4882
|
+
|
|
4883
|
+
##### 500 — Unexpected server error.
|
|
4884
|
+
|
|
4885
|
+
```json
|
|
4886
|
+
{
|
|
4887
|
+
"status": 500,
|
|
4888
|
+
"message": "Bad request.",
|
|
4889
|
+
"data": null
|
|
4890
|
+
}
|
|
4891
|
+
```
|
|
4892
|
+
|
|
4893
|
+
### OAuth 2.0 protected resource metadata
|
|
4894
|
+
|
|
4895
|
+
`GET /.well-known/oauth-protected-resource`
|
|
4896
|
+
|
|
4897
|
+
RFC 9728. Identifies this API as a protected resource, the
|
|
4898
|
+
* authorization server(s) that can issue tokens for it, and the scopes it
|
|
4899
|
+
* accepts. `scopes_supported` deliberately excludes `offline_access` — per the
|
|
4900
|
+
* MCP specification, requesting a refresh token is a client concern, not
|
|
4901
|
+
* something a resource is protected by. Also referenced from the
|
|
4902
|
+
* `WWW-Authenticate: Bearer resource_metadata="..."` challenge on a 401/403.
|
|
4903
|
+
* Per RFC 8615, the response is the bare metadata object itself — never this
|
|
4904
|
+
* API's usual `{status, data, message}` envelope. The `authorization_servers` entry names the host that owns the browser-facing flow — start every integration by fetching `{authorization_servers[0]}/.well-known/oauth-authorization-server` (RFC 8414) from there, not from this API.
|
|
4905
|
+
|
|
4906
|
+
**Authentication:** none (public endpoint).
|
|
4907
|
+
|
|
4908
|
+
#### Responses
|
|
4909
|
+
|
|
4910
|
+
##### 200 — The protected resource metadata
|
|
4911
|
+
|
|
4912
|
+
```json
|
|
4913
|
+
{
|
|
4914
|
+
"resource": "string",
|
|
4915
|
+
"authorization_servers": [
|
|
4916
|
+
"string"
|
|
4917
|
+
],
|
|
4918
|
+
"scopes_supported": [
|
|
4919
|
+
"string"
|
|
4920
|
+
],
|
|
4921
|
+
"bearer_methods_supported": [
|
|
4922
|
+
"header"
|
|
4923
|
+
]
|
|
4924
|
+
}
|
|
4925
|
+
```
|
|
4926
|
+
|
|
4927
|
+
##### 500 — Unexpected server error.
|
|
4928
|
+
|
|
4929
|
+
```json
|
|
4930
|
+
{
|
|
4931
|
+
"status": 500,
|
|
4932
|
+
"message": "Bad request.",
|
|
4933
|
+
"data": null
|
|
4934
|
+
}
|
|
4935
|
+
```
|
|
4936
|
+
|
|
4703
4937
|
## Signing
|
|
4704
4938
|
|
|
4705
4939
|
### View public document
|
|
@@ -5319,7 +5553,7 @@ The signer declines to sign the document, giving a reason. Uses the signer acces
|
|
|
5319
5553
|
|
|
5320
5554
|
Fields (`application/json`):
|
|
5321
5555
|
|
|
5322
|
-
- `decline_reason` (string, required) — Descriptive reason for declining.
|
|
5556
|
+
- `decline_reason` (string, required) — Descriptive reason for declining. Up to 2000 characters; longer values return 400.
|
|
5323
5557
|
|
|
5324
5558
|
Example:
|
|
5325
5559
|
|
|
@@ -5380,8 +5614,8 @@ Example:
|
|
|
5380
5614
|
```json
|
|
5381
5615
|
{
|
|
5382
5616
|
"document_ids": [
|
|
5383
|
-
"
|
|
5384
|
-
"
|
|
5617
|
+
"example_id_30",
|
|
5618
|
+
"example_id_31"
|
|
5385
5619
|
]
|
|
5386
5620
|
}
|
|
5387
5621
|
```
|
|
@@ -5431,15 +5665,15 @@ Decline several documents in one request. Uses the signer access code.
|
|
|
5431
5665
|
Fields (`application/json`):
|
|
5432
5666
|
|
|
5433
5667
|
- `document_ids` (array, required) — IDs of the documents to decline.
|
|
5434
|
-
- `decline_reason` (string, required) — Reason for declining.
|
|
5668
|
+
- `decline_reason` (string, required) — Reason for declining. Up to 2000 characters; longer values return 400.
|
|
5435
5669
|
|
|
5436
5670
|
Example:
|
|
5437
5671
|
|
|
5438
5672
|
```json
|
|
5439
5673
|
{
|
|
5440
5674
|
"document_ids": [
|
|
5441
|
-
"
|
|
5442
|
-
"
|
|
5675
|
+
"example_id_30",
|
|
5676
|
+
"example_id_31"
|
|
5443
5677
|
],
|
|
5444
5678
|
"decline_reason": "Unfavorable terms."
|
|
5445
5679
|
}
|
|
@@ -6770,7 +7004,7 @@ The `status` field of a template is one of:
|
|
|
6770
7004
|
"data": [
|
|
6771
7005
|
{
|
|
6772
7006
|
"resource": "template",
|
|
6773
|
-
"id": "
|
|
7007
|
+
"id": "example_id_32",
|
|
6774
7008
|
"name": "template.pdf",
|
|
6775
7009
|
"document_name": "string",
|
|
6776
7010
|
"message": "string",
|
|
@@ -7119,7 +7353,7 @@ Retrieve the delivery history for webhooks sent to the account's configured endp
|
|
|
7119
7353
|
"data": [
|
|
7120
7354
|
{
|
|
7121
7355
|
"resource": "activity_dispatching_history",
|
|
7122
|
-
"id": "
|
|
7356
|
+
"id": "example_id_33",
|
|
7123
7357
|
"event": "document_ready",
|
|
7124
7358
|
"activity_id": 456,
|
|
7125
7359
|
"endpoint": "https://example.com/example-url-13",
|
|
@@ -7180,7 +7414,7 @@ Manually retry a webhook delivery for a specific entry, without waiting for auto
|
|
|
7180
7414
|
{
|
|
7181
7415
|
"data": {
|
|
7182
7416
|
"resource": "activity_dispatching_history",
|
|
7183
|
-
"id": "
|
|
7417
|
+
"id": "example_id_33",
|
|
7184
7418
|
"event": "document_ready",
|
|
7185
7419
|
"activity_id": 456,
|
|
7186
7420
|
"endpoint": "https://example.com/example-url-13",
|
package/docs/migration-v2.md
CHANGED
|
@@ -4,14 +4,18 @@ Version 2 publishes the Node.js SDK at `@assinafy/cli/api` and requires Node.js
|
|
|
4
4
|
`>=22.12.0`.
|
|
5
5
|
|
|
6
6
|
- Credentialed clients now require HTTPS, reject redirects, and reject base URLs
|
|
7
|
-
containing a query or fragment.
|
|
8
|
-
|
|
7
|
+
containing a query or fragment. `allowInsecureHttp: true` permits a plaintext
|
|
8
|
+
base URL only on a loopback host (`localhost`, `127.0.0.0/8`, `[::1]`), so a key
|
|
9
|
+
can never be sent in cleartext to a remote host.
|
|
9
10
|
- Resource IDs, artifact names, sort fields, dates, mutually exclusive CLI
|
|
10
11
|
options, and signer-code authentication are validated before a request.
|
|
11
12
|
- Published `{ status, message }` bodies and delete `data: []` bodies are now
|
|
12
13
|
returned as `IStatusResponse` and `IEmptyResult` instead of being discarded.
|
|
13
14
|
- Phone-only signers in `uploadAndRequestSignatures` default to WhatsApp
|
|
14
15
|
verification and notification. Explicit signer controls still take precedence.
|
|
16
|
+
- `uploadAndRequestSignatures` rejects with `PartialWorkflowError` when it fails
|
|
17
|
+
after the upload, exposing the `documentId` and `signerIds` it already created
|
|
18
|
+
so callers can clean up or resume without searching for orphans.
|
|
15
19
|
- Signer artifact downloads perform an identity preflight because older sandbox
|
|
16
20
|
deployments did not enforce the documented access code on the raw download route.
|
|
17
21
|
|