@assinafy/sdk 2.0.0 → 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.
@@ -0,0 +1,169 @@
1
+ # Releasing
2
+
3
+ GitLab is the canonical repository and push-mirrors branches and tags to
4
+ GitHub. Publishing is performed by `.github/workflows/release.yml` when GitHub
5
+ receives a tag matching `v*`; a mirrored tag does not create a GitHub `release`
6
+ event, and the workflow intentionally does not depend on one.
7
+
8
+ ## Release support matrix
9
+
10
+ | Runtime | Release responsibility |
11
+ | --- | --- |
12
+ | Bun 1.4.0 | Locked install, tests, build, contract checks, and packaging |
13
+ | Node.js 22 | Minimum supported consumer runtime |
14
+ | Node.js 24 LTS | Packaging and registry publishing runtime |
15
+ | Node.js 26 Current | Forward-compatibility consumer test |
16
+
17
+ Keep this table, `package.json`, GitLab CI, and the GitHub workflows synchronized
18
+ when changing runtime support.
19
+
20
+ ## One-time registry setup
21
+
22
+ ### npm trusted publishing
23
+
24
+ Configure the npm package `@assinafy/sdk` with a GitHub Actions trusted
25
+ publisher using these repository coordinates:
26
+
27
+ | npm setting | Value |
28
+ | --- | --- |
29
+ | Organization or user | `assinafy` |
30
+ | Repository | `typescript-sdk` |
31
+ | Workflow filename | `release.yml` |
32
+ | Environment | `release` |
33
+ | Allowed actions | `npm publish` |
34
+
35
+ The `publish-npm` job grants only `contents: read` and `id-token: write`.
36
+ Modern npm exchanges GitHub's short-lived OIDC identity for publish credentials;
37
+ no long-lived `NPM_TOKEN` is required. Test trusted publishing before deleting a
38
+ legacy token, then remove that token from repository and organization secrets.
39
+ Keep package access **public** and select npm's most restrictive publishing
40
+ access option: **Require two-factor authentication and disallow bypass 2FA
41
+ tokens**. Trusted-publisher OIDC remains compatible with that setting.
42
+
43
+ ### GitHub Packages
44
+
45
+ The `publish-gh` job uses the workflow-scoped `GITHUB_TOKEN` with
46
+ `packages: write`. Confirm that organization policy permits Actions to publish
47
+ the `@assinafy` scope and that the package remains linked to this repository.
48
+ No separate personal access token should be stored.
49
+
50
+ ### Sandbox integration environment
51
+
52
+ Create a protected GitHub environment named `sandbox`. Restrict deployments to
53
+ the mirrored `main` branch, require reviewer approval, and store these required
54
+ environment secrets:
55
+
56
+ - `ASSINAFY_API_KEY`
57
+ - `ASSINAFY_ACCOUNT_ID`
58
+
59
+ The `disposable-full` mode also requires `ASSINAFY_TEST_EMAIL_PRIMARY` and
60
+ `ASSINAFY_TEST_EMAIL_SECONDARY`. Optional coverage uses
61
+ `ASSINAFY_TEST_WEBHOOK_URL`, `ASSINAFY_TEST_LOGIN_EMAIL`,
62
+ `ASSINAFY_TEST_LOGIN_PASSWORD`, `ASSINAFY_SIGNER_ACCESS_CODE`,
63
+ `ASSINAFY_SIGNER_OTP`, and `ASSINAFY_PUBLIC_DOCUMENT_ID`.
64
+
65
+ Keep secret values out of repository variables, files, and logs. Run the manual
66
+ **Sandbox integration** workflow from mirrored `main`; use `read-only` first
67
+ and select `disposable-full` only for a deliberate reversible test run.
68
+
69
+ ### Mirror and tag protection
70
+
71
+ The GitLab push mirror must include tags and be able to update the GitHub
72
+ repository. Protect `v*` tags in GitLab so only release maintainers can create
73
+ them, and add a GitHub tag ruleset that restricts creating, updating, and
74
+ deleting the same pattern to the mirror/release maintainers. Protect the GitHub
75
+ `release` environment with required reviewers and a deployment tag rule for
76
+ `v*`. GitHub Actions must be enabled on the mirror.
77
+
78
+ ## Preparing a release
79
+
80
+ 1. Merge the complete change through GitLab and confirm both GitLab and mirrored
81
+ GitHub CI are green.
82
+ 2. Choose the semantic version and update `package.json`. Keep the tag exactly
83
+ `v<package-version>`; the workflow rejects a mismatch.
84
+ 3. Update `CHANGELOG.md`, API coverage, compatibility notes, and public examples
85
+ for all user-visible changes.
86
+ 4. Install and run the complete local release gate from a clean checkout:
87
+
88
+ ```sh
89
+ bun install --frozen-lockfile
90
+ bun run verify
91
+ bun run audit
92
+ bun run audit:api
93
+ ```
94
+
95
+ 5. For API changes, run the sandbox smoke script against a dedicated account.
96
+ Start read-only:
97
+
98
+ ```sh
99
+ ASSINAFY_API_KEY='...' \
100
+ ASSINAFY_ACCOUNT_ID='...' \
101
+ ASSINAFY_BASE_URL='https://sandbox.assinafy.com.br/v1' \
102
+ bun scripts/live-smoke.ts
103
+ ```
104
+
105
+ Then run the reversible suite with two controlled recipients:
106
+
107
+ ```sh
108
+ ASSINAFY_API_KEY='...' \
109
+ ASSINAFY_ACCOUNT_ID='...' \
110
+ ASSINAFY_BASE_URL='https://sandbox.assinafy.com.br/v1' \
111
+ ASSINAFY_TEST_EMAIL_PRIMARY='first@example.com' \
112
+ ASSINAFY_TEST_EMAIL_SECONDARY='second@example.com' \
113
+ bun scripts/live-smoke.ts --all
114
+ ```
115
+
116
+ The suite creates and force-deletes a disposable workspace, but an
117
+ interrupted process can still leave fixtures behind; inspect the sandbox
118
+ before releasing. Treat every `FAIL` as a release blocker and review each
119
+ `SKIP` to confirm its password, provider-token, signer-code/OTP, legal-action,
120
+ final-artifact, or webhook-receiver prerequisite was intentionally absent.
121
+ Never use production credentials or uncontrolled recipients.
122
+
123
+ 6. Commit the version and release notes, merge them to the canonical default
124
+ branch, then create a signed or annotated `v<version>` tag on that exact
125
+ commit and push the tag to GitLab.
126
+ 7. Confirm that the tag reaches GitHub and starts the **Release** workflow. Do
127
+ not create or move a second tag to work around mirror delay.
128
+
129
+ ## What the workflow publishes
130
+
131
+ The workflow serializes releases repository-wide and performs these steps:
132
+
133
+ 1. verify that the tag and `package.json` versions match;
134
+ 2. install from `bun.lock`, run `verify`, dependency and API-contract checks,
135
+ and build once;
136
+ 3. create one `.tgz` with lifecycle scripts disabled and record its SHA-256;
137
+ 4. upload that archive and checksum as a seven-day workflow artifact;
138
+ 5. verify and publish the archive to npm through trusted-publisher OIDC; and
139
+ 6. verify and publish the **same bytes** to GitHub Packages using
140
+ `GITHUB_TOKEN`.
141
+
142
+ The GitHub Packages job depends on npm publishing, preventing a GitHub-only
143
+ release when npm fails. Both registry jobs validate `SHA256SUMS`; neither
144
+ rebuilds or repacks the SDK. This immutable-artifact flow is part of the release
145
+ contract and must be preserved when editing the workflow.
146
+
147
+ ## Verification and recovery
148
+
149
+ After publishing, confirm that the expected version appears on npm and GitHub
150
+ Packages, that a clean Node.js consumer can import both the ESM and CommonJS
151
+ entrypoints, and that registry downloads have the expected checksum.
152
+
153
+ If packaging or npm publishing fails, fix the source, increment or retain the
154
+ version as registry state allows, and create a new tag only after review. Never
155
+ move a tag that has published a package.
156
+
157
+ Do not rerun an old release after changing its workflow or trusted-publisher
158
+ coordinates: GitHub reruns use the original commit and ref. Merge the fix and
159
+ create a reviewed new version and tag instead.
160
+
161
+ If npm succeeds and GitHub Packages fails, rerun only the failed job while the
162
+ original seven-day workflow artifact is retained. This preserves the exact
163
+ archive already published to npm. Do not repack an approximation or unpublish a
164
+ released npm version. If the artifact has expired, stop and review recovery with
165
+ the maintainers before changing workflow dependencies or registry state.
166
+
167
+ For a defective published release, prefer deprecating the affected version and
168
+ shipping a reviewed patch. Record the incident and remediation in the
169
+ changelog and any applicable security advisory.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@assinafy/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.2",
4
+ "packageManager": "bun@1.4.0",
4
5
  "description": "TypeScript SDK for Assinafy API - Digital signature platform",
5
6
  "type": "commonjs",
6
7
  "main": "dist/index.js",
@@ -23,12 +24,16 @@
23
24
  "scripts": {
24
25
  "build": "tsup src/index.ts --format cjs,esm --dts --clean",
25
26
  "test": "bun test",
26
- "lint": "eslint src",
27
- "lint:fix": "eslint src --fix",
27
+ "test:coverage": "bun test --coverage",
28
+ "lint": "eslint src scripts --max-warnings=0",
29
+ "lint:fix": "eslint src scripts --fix",
28
30
  "lint:pkg": "publint --strict && attw --pack .",
29
- "prepublishOnly": "bun run build",
30
- "release": "bun run typecheck && bun run lint && bun test && bun run build && npm publish --access public && npm publish --registry=https://npm.pkg.github.com",
31
- "typecheck": "tsc --noEmit"
31
+ "audit": "bun audit",
32
+ "audit:api": "bun scripts/api-contract-audit.ts",
33
+ "prepack": "bun run build",
34
+ "prepublishOnly": "bun run verify && bun run audit",
35
+ "typecheck": "bun ./node_modules/@typescript/native/bin/tsc --noEmit && bun ./node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.scripts.json && bun ./node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.tests.json",
36
+ "verify": "bun run typecheck && bun run lint && bun run test:coverage && bun run build && bun run lint:pkg"
32
37
  },
33
38
  "keywords": [
34
39
  "assinafy",
@@ -61,21 +66,29 @@
61
66
  "homepage": "https://github.com/assinafy/typescript-sdk/#readme",
62
67
  "devDependencies": {
63
68
  "@arethetypeswrong/cli": "^0.18.5",
64
- "@eslint/js": "^9.0.0",
65
- "@types/bun": "^1.3.0",
66
- "@types/node": "^26.1.1",
67
- "eslint": "^9.0.0",
68
- "publint": "^0.3.21",
69
- "tsup": "^8.0.0",
70
- "typescript": "^5.0.0",
71
- "typescript-eslint": "^8.0.0"
69
+ "@eslint/js": "^10.0.1",
70
+ "@types/bun": "^1.4.0",
71
+ "@types/node": "^22.20.1",
72
+ "@typescript/native": "npm:typescript@^7.0.2",
73
+ "eslint": "^10.9.1",
74
+ "publint": "^0.3.24",
75
+ "tsup": "^8.5.1",
76
+ "typescript": "^6.0.3",
77
+ "typescript-eslint": "^8.68.0"
72
78
  },
73
79
  "dependencies": {
74
- "axios": "^1.6.0"
80
+ "axios": "^1.20.0"
81
+ },
82
+ "overrides": {
83
+ "esbuild": "0.28.2",
84
+ "brace-expansion": "5.0.9"
75
85
  },
76
86
  "files": [
77
87
  "dist",
88
+ "docs",
78
89
  "README.md",
90
+ "CHANGELOG.md",
91
+ "SECURITY.md",
79
92
  "LICENSE"
80
93
  ]
81
94
  }