@assinafy/cli 1.0.2 → 2.0.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.
Files changed (69) hide show
  1. package/README.md +86 -38
  2. package/THIRD_PARTY_NOTICES.md +972 -0
  3. package/dist/api.cjs +1965 -0
  4. package/dist/api.cjs.map +1 -0
  5. package/dist/api.js +1909 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/cli.cjs +3018 -1560
  8. package/dist/types/api/client.d.ts +88 -0
  9. package/dist/types/api/client.d.ts.map +1 -0
  10. package/dist/types/api/errors.d.ts +28 -0
  11. package/dist/types/api/errors.d.ts.map +1 -0
  12. package/dist/types/api/index.d.ts +21 -0
  13. package/dist/types/api/index.d.ts.map +1 -0
  14. package/dist/types/api/resources/assignments.d.ts +39 -0
  15. package/dist/types/api/resources/assignments.d.ts.map +1 -0
  16. package/dist/types/api/resources/authentication.d.ts +55 -0
  17. package/dist/types/api/resources/authentication.d.ts.map +1 -0
  18. package/dist/types/api/resources/base.d.ts +35 -0
  19. package/dist/types/api/resources/base.d.ts.map +1 -0
  20. package/dist/types/api/resources/documents.d.ts +124 -0
  21. package/dist/types/api/resources/documents.d.ts.map +1 -0
  22. package/dist/types/api/resources/fields.d.ts +57 -0
  23. package/dist/types/api/resources/fields.d.ts.map +1 -0
  24. package/dist/types/api/resources/signer-documents.d.ts +72 -0
  25. package/dist/types/api/resources/signer-documents.d.ts.map +1 -0
  26. package/dist/types/api/resources/signers.d.ts +25 -0
  27. package/dist/types/api/resources/signers.d.ts.map +1 -0
  28. package/dist/types/api/resources/tags.d.ts +37 -0
  29. package/dist/types/api/resources/tags.d.ts.map +1 -0
  30. package/dist/types/api/resources/templates.d.ts +21 -0
  31. package/dist/types/api/resources/templates.d.ts.map +1 -0
  32. package/dist/types/api/resources/users.d.ts +14 -0
  33. package/dist/types/api/resources/users.d.ts.map +1 -0
  34. package/dist/types/api/resources/webhooks.d.ts +17 -0
  35. package/dist/types/api/resources/webhooks.d.ts.map +1 -0
  36. package/dist/types/api/resources/workspaces.d.ts +32 -0
  37. package/dist/types/api/resources/workspaces.d.ts.map +1 -0
  38. package/dist/types/api/support/webhook-verifier.d.ts +43 -0
  39. package/dist/types/api/support/webhook-verifier.d.ts.map +1 -0
  40. package/dist/types/api/types.d.ts +926 -0
  41. package/dist/types/api/types.d.ts.map +1 -0
  42. package/dist/types/api/utils.d.ts +34 -0
  43. package/dist/types/api/utils.d.ts.map +1 -0
  44. package/docs/README.md +9 -1
  45. package/docs/api-operations.json +718 -0
  46. package/docs/api-reference.md +7228 -0
  47. package/docs/assignments.md +21 -1
  48. package/docs/auth.md +28 -12
  49. package/docs/config.md +0 -1
  50. package/docs/docs.md +0 -1
  51. package/docs/documents.md +45 -6
  52. package/docs/fields.md +4 -2
  53. package/docs/login.md +0 -1
  54. package/docs/logout.md +0 -1
  55. package/docs/migration-v2.md +20 -0
  56. package/docs/releasing.md +42 -0
  57. package/docs/sdk-reference.md +344 -0
  58. package/docs/send.md +1 -2
  59. package/docs/signer.md +44 -19
  60. package/docs/signers.md +2 -3
  61. package/docs/tags.md +0 -1
  62. package/docs/templates.md +3 -3
  63. package/docs/users.md +85 -0
  64. package/docs/webhooks.md +1 -16
  65. package/docs/whoami.md +0 -1
  66. package/docs/workspaces.md +109 -10
  67. package/install.ps1 +117 -13
  68. package/install.sh +165 -30
  69. package/package.json +37 -16
package/install.sh CHANGED
@@ -1,59 +1,99 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
+ assinafy_tmp_dir=""
5
+ assinafy_replacement=""
6
+
7
+ cleanup() {
8
+ if [ -n "$assinafy_replacement" ]; then
9
+ rm -f "$assinafy_replacement"
10
+ fi
11
+ if [ -n "$assinafy_tmp_dir" ]; then
12
+ rm -rf "$assinafy_tmp_dir"
13
+ fi
14
+ }
15
+
4
16
  main() {
5
17
  local requested_version="${1:-}"
6
18
  local github_base="${GITHUB_BASE:-https://github.com}"
7
19
  local repo="${ASSINAFY_REPO:-assinafy/assinafy-cli}"
8
20
  local install_dir="${ASSINAFY_INSTALL:-$HOME/.assinafy}"
9
21
  local bin_dir="$install_dir/bin"
10
- local tmp_dir
11
- tmp_dir="$(mktemp -d)"
12
- trap 'rm -rf "$tmp_dir"' EXIT
22
+ assinafy_tmp_dir="$(mktemp -d)"
23
+ trap cleanup EXIT
13
24
 
14
25
  setup_colors
15
26
  check_prerequisites
16
27
  validate_github_base "$github_base"
17
28
 
18
- local target archive_url archive extract_dir executable installed_version
29
+ local target archive_url checksums_url archive checksums_file extract_dir executable staged_executable installed_version archive_version
19
30
  target="$(detect_target)"
20
31
  archive_url="$(release_url "$github_base" "$repo" "$requested_version" "$target")"
21
- archive="$tmp_dir/assinafy.tar.gz"
22
- extract_dir="$tmp_dir/extract"
32
+ checksums_url="$(checksums_release_url "$github_base" "$repo" "$requested_version")"
33
+ archive="$assinafy_tmp_dir/assinafy.tar.gz"
34
+ checksums_file="$assinafy_tmp_dir/SHA256SUMS"
35
+ extract_dir="$assinafy_tmp_dir/extract"
23
36
  executable="$bin_dir/assinafy"
37
+ staged_executable="$extract_dir/assinafy"
24
38
 
25
39
  info "Downloading Assinafy CLI for $target"
26
40
  curl -fsSL "$archive_url" -o "$archive"
27
41
 
28
- mkdir -p "$extract_dir" "$bin_dir" "$install_dir"
42
+ info "Verifying checksum"
43
+ curl -fsSL "$checksums_url" -o "$checksums_file"
44
+ verify_checksum "$archive" "$checksums_file" "assinafy-$target.tar.gz"
45
+ validate_archive "$archive" "$target"
46
+
47
+ mkdir -p "$extract_dir"
29
48
  tar -xzf "$archive" -C "$extract_dir"
49
+ if [ -n "$(find "$extract_dir" ! -type d ! -type f -print -quit)" ]; then
50
+ fail "Release archive contained a link or special file"
51
+ fi
30
52
 
31
- if [ ! -f "$extract_dir/assinafy" ]; then
53
+ if [ ! -f "$staged_executable" ]; then
32
54
  fail "Release archive did not contain the assinafy executable"
33
55
  fi
56
+ if [ ! -f "$extract_dir/VERSION" ]; then
57
+ fail "Release archive did not contain VERSION"
58
+ fi
59
+ archive_version="$(<"$extract_dir/VERSION")"
60
+ if ! [[ "$archive_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
61
+ fail "Release archive contained an invalid VERSION"
62
+ fi
63
+ if [ -n "$requested_version" ] && [ "$archive_version" != "${requested_version#v}" ]; then
64
+ fail "Release archive version $archive_version does not match requested version ${requested_version#v}"
65
+ fi
34
66
 
35
- cp "$extract_dir/assinafy" "$executable"
36
- chmod 755 "$executable"
37
-
38
- if [ -f "$extract_dir/README.md" ]; then cp "$extract_dir/README.md" "$install_dir/README.md"; fi
39
- if [ -f "$extract_dir/LICENSE" ]; then cp "$extract_dir/LICENSE" "$install_dir/LICENSE"; fi
40
- if [ -f "$extract_dir/VERSION" ]; then cp "$extract_dir/VERSION" "$install_dir/VERSION"; fi
41
-
67
+ chmod 755 "$staged_executable"
42
68
  if command -v xattr >/dev/null 2>&1; then
43
- xattr -d com.apple.quarantine "$executable" >/dev/null 2>&1 || true
69
+ xattr -d com.apple.quarantine "$staged_executable" >/dev/null 2>&1 || true
44
70
  fi
45
71
 
46
- installed_version="$("$executable" --version 2>/dev/null || true)"
47
- if [ -z "$installed_version" ]; then
48
- fail "Installed executable did not run. Confirm Node.js 18+ is available on PATH."
72
+ if ! installed_version="$("$staged_executable" --version 2>/dev/null)" || [ -z "$installed_version" ]; then
73
+ fail "Installed executable did not run. Confirm Node.js 22.12+ is available on PATH."
49
74
  fi
75
+ if [ "$installed_version" != "@assinafy/cli v$archive_version" ]; then
76
+ fail "Executable version does not match archive VERSION: $installed_version"
77
+ fi
78
+
79
+ mkdir -p "$bin_dir" "$install_dir"
80
+ assinafy_replacement="$(mktemp "$bin_dir/.assinafy.XXXXXX")"
81
+ cp "$staged_executable" "$assinafy_replacement"
82
+ chmod 755 "$assinafy_replacement"
83
+ mv -f "$assinafy_replacement" "$executable"
84
+ assinafy_replacement=""
85
+
86
+ if [ -f "$extract_dir/README.md" ]; then cp "$extract_dir/README.md" "$install_dir/README.md"; fi
87
+ if [ -f "$extract_dir/LICENSE" ]; then cp "$extract_dir/LICENSE" "$install_dir/LICENSE"; fi
88
+ if [ -f "$extract_dir/THIRD_PARTY_NOTICES.md" ]; then cp "$extract_dir/THIRD_PARTY_NOTICES.md" "$install_dir/THIRD_PARTY_NOTICES.md"; fi
89
+ if [ -f "$extract_dir/VERSION" ]; then cp "$extract_dir/VERSION" "$install_dir/VERSION"; fi
50
90
 
51
91
  ensure_path "$bin_dir"
52
92
  success "Installed $installed_version to $executable"
53
93
 
54
94
  if ! path_has "$bin_dir"; then
55
95
  warn "$bin_dir is not on PATH in this shell. Open a new shell or run:"
56
- printf ' export PATH="%s:$PATH"\n' "$bin_dir"
96
+ printf ' export PATH="%s:%s"\n' "$bin_dir" "\$PATH"
57
97
  fi
58
98
  }
59
99
 
@@ -63,14 +103,12 @@ setup_colors() {
63
103
  green="$(printf '\033[32m')"
64
104
  yellow="$(printf '\033[33m')"
65
105
  blue="$(printf '\033[34m')"
66
- bold="$(printf '\033[1m')"
67
106
  reset="$(printf '\033[0m')"
68
107
  else
69
108
  red=""
70
109
  green=""
71
110
  yellow=""
72
111
  blue=""
73
- bold=""
74
112
  reset=""
75
113
  fi
76
114
  }
@@ -103,10 +141,10 @@ check_prerequisites() {
103
141
  need_cmd tar
104
142
  need_cmd node
105
143
 
106
- local node_major
107
- node_major="$(node -p "Number(process.versions.node.split('.')[0])" 2>/dev/null || echo 0)"
108
- if [ "$node_major" -lt 18 ]; then
109
- fail "Node.js 18+ is required. Found: $(node --version 2>/dev/null || echo unknown)"
144
+ local node_supported
145
+ node_supported="$(node -p "const [major, minor] = process.versions.node.split('.').map(Number); major > 22 || (major === 22 && minor >= 12)" 2>/dev/null || echo false)"
146
+ if [ "$node_supported" != "true" ]; then
147
+ fail "Node.js 22.12+ is required. Found: $(node --version 2>/dev/null || echo unknown)"
110
148
  fi
111
149
  }
112
150
 
@@ -155,6 +193,95 @@ release_url() {
155
193
  printf '%s/releases/download/v%s/assinafy-%s.tar.gz' "$base" "$requested_version" "$target"
156
194
  }
157
195
 
196
+ checksums_release_url() {
197
+ local github_base="$1"
198
+ local repo="$2"
199
+ local requested_version="$3"
200
+ local base
201
+ base="${github_base%/}/${repo}"
202
+
203
+ if [ -z "$requested_version" ]; then
204
+ printf '%s/releases/latest/download/SHA256SUMS' "$base"
205
+ return
206
+ fi
207
+
208
+ printf '%s/releases/download/v%s/SHA256SUMS' "$base" "${requested_version#v}"
209
+ }
210
+
211
+ # Verify $archive's SHA-256 against the line for $expected_name in $checksums_file.
212
+ verify_checksum() {
213
+ local archive="$1"
214
+ local checksums_file="$2"
215
+ local expected_name="$3"
216
+ local expected_hash actual_hash
217
+
218
+ if ! expected_hash="$(awk -v name="$expected_name" '
219
+ $2 == name && NF == 2 { count++; hash = $1 }
220
+ END { if (count == 1) print hash; else exit 1 }
221
+ ' "$checksums_file")"; then
222
+ fail "SHA256SUMS did not contain an entry for $expected_name"
223
+ fi
224
+ if ! [[ "$expected_hash" =~ ^[[:xdigit:]]{64}$ ]]; then
225
+ fail "SHA256SUMS contained an invalid hash for $expected_name"
226
+ fi
227
+ expected_hash="$(printf '%s\n' "$expected_hash" | tr '[:upper:]' '[:lower:]')"
228
+
229
+ if command -v shasum >/dev/null 2>&1; then
230
+ actual_hash="$(shasum -a 256 "$archive" | awk '{print $1}')"
231
+ elif command -v sha256sum >/dev/null 2>&1; then
232
+ actual_hash="$(sha256sum "$archive" | awk '{print $1}')"
233
+ else
234
+ fail "Required command not found: shasum or sha256sum"
235
+ fi
236
+
237
+ if [ "$actual_hash" != "$expected_hash" ]; then
238
+ fail "Checksum mismatch for $expected_name: expected $expected_hash, got $actual_hash"
239
+ fi
240
+ }
241
+
242
+ validate_archive() {
243
+ local archive="$1"
244
+ local target="$2"
245
+ local entry expected executable_count=0 version_count=0
246
+ if [[ "$target" == windows-* ]]; then
247
+ expected='assinafy.cmd|assinafy.cjs'
248
+ else
249
+ expected='assinafy'
250
+ fi
251
+
252
+ while IFS= read -r entry; do
253
+ case "$entry" in
254
+ '' | /* | ../* | */../* | */.. | *\\*) fail "Release archive contained an unsafe path" ;;
255
+ esac
256
+ if [[ "$entry" =~ [^[:print:]] ]]; then
257
+ fail "Release archive contained a control character in a path"
258
+ fi
259
+ case "$entry" in
260
+ assinafy | assinafy.cmd | assinafy.cjs)
261
+ if [[ "$entry" =~ ^($expected)$ ]]; then
262
+ executable_count=$((executable_count + 1))
263
+ else
264
+ fail "Release archive contained an executable for the wrong platform"
265
+ fi
266
+ ;;
267
+ VERSION) version_count=$((version_count + 1)) ;;
268
+ README.md | LICENSE | THIRD_PARTY_NOTICES.md | docs/*.md | docs/api-operations.json) ;;
269
+ *) fail "Release archive contained an unexpected path: $entry" ;;
270
+ esac
271
+ done < <(tar -tzf "$archive")
272
+
273
+ if [ "$version_count" -ne 1 ]; then
274
+ fail "Release archive must contain exactly one VERSION file"
275
+ fi
276
+ if [[ "$target" == windows-* ]]; then
277
+ if [ "$executable_count" -ne 2 ]; then
278
+ fail "Release archive must contain both Windows executable files"
279
+ fi
280
+ elif [ "$executable_count" -ne 1 ]; then
281
+ fail "Release archive must contain exactly one executable"
282
+ fi
283
+ }
284
+
158
285
  path_has() {
159
286
  case ":${PATH:-}:" in
160
287
  *":$1:"*) return 0 ;;
@@ -174,19 +301,25 @@ append_once() {
174
301
 
175
302
  ensure_path() {
176
303
  local bin_dir="$1"
304
+ local escaped_bin_dir
177
305
  if [ "${ASSINAFY_NO_PATH_UPDATE:-}" = "1" ] || path_has "$bin_dir"; then
178
306
  return
179
307
  fi
308
+ if [[ "$bin_dir" =~ [^[:print:]] ]]; then
309
+ warn "Install path contains control characters; add it to PATH manually."
310
+ return
311
+ fi
312
+ printf -v escaped_bin_dir '%q' "$bin_dir"
180
313
 
181
314
  case "$(basename "${SHELL:-}")" in
182
315
  fish)
183
- append_once "$HOME/.config/fish/config.fish" "fish_add_path \"$bin_dir\" # Assinafy CLI"
316
+ append_once "$HOME/.config/fish/config.fish" "fish_add_path -- $escaped_bin_dir # Assinafy CLI"
184
317
  ;;
185
318
  zsh)
186
- append_once "$HOME/.zshrc" "export PATH=\"$bin_dir:\$PATH\" # Assinafy CLI"
319
+ append_once "$HOME/.zshrc" "export PATH=$escaped_bin_dir:\$PATH # Assinafy CLI"
187
320
  ;;
188
321
  bash)
189
- append_once "$HOME/.bashrc" "export PATH=\"$bin_dir:\$PATH\" # Assinafy CLI"
322
+ append_once "$HOME/.bashrc" "export PATH=$escaped_bin_dir:\$PATH # Assinafy CLI"
190
323
  ;;
191
324
  *)
192
325
  warn "Add $bin_dir to PATH to run assinafy from any directory."
@@ -194,4 +327,6 @@ ensure_path() {
194
327
  esac
195
328
  }
196
329
 
197
- main "$@"
330
+ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
331
+ main "$@"
332
+ fi
package/package.json CHANGED
@@ -1,22 +1,36 @@
1
1
  {
2
2
  "name": "@assinafy/cli",
3
- "version": "1.0.2",
3
+ "version": "2.0.2",
4
4
  "description": "The official command-line interface for the Assinafy digital-signature API",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
8
- "node": ">=22"
8
+ "node": ">=22.12.0"
9
9
  },
10
10
  "bin": {
11
11
  "assinafy": "./dist/cli.cjs"
12
12
  },
13
+ "exports": {
14
+ "./api": {
15
+ "types": "./dist/types/api/index.d.ts",
16
+ "import": "./dist/api.js",
17
+ "require": "./dist/api.cjs"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
13
21
  "files": [
14
22
  "dist/cli.cjs",
23
+ "dist/api.js",
24
+ "dist/api.js.map",
25
+ "dist/api.cjs",
26
+ "dist/api.cjs.map",
27
+ "dist/types/",
15
28
  "docs/",
16
29
  "install.sh",
17
30
  "install.ps1",
18
31
  "README.md",
19
- "LICENSE"
32
+ "LICENSE",
33
+ "THIRD_PARTY_NOTICES.md"
20
34
  ],
21
35
  "keywords": [
22
36
  "assinafy",
@@ -40,31 +54,38 @@
40
54
  "scripts": {
41
55
  "dev": "tsx src/cli.ts",
42
56
  "dev:watch": "tsx --watch src/cli.ts",
43
- "build": "tsup",
57
+ "build": "tsup && tsup --config tsup.api.config.ts && tsc -p tsconfig.build.json",
44
58
  "typecheck": "tsc --noEmit",
45
59
  "lint": "biome check .",
46
60
  "lint:fix": "biome check --write .",
47
61
  "test": "vitest run",
62
+ "test:sandbox": "npm run build && node scripts/sandbox-smoke.mjs",
48
63
  "test:watch": "vitest",
49
64
  "docs": "npm run build && node scripts/gen-docs.mjs",
65
+ "docs:api": "node scripts/gen-api-reference.mjs",
66
+ "verify:api-docs": "node scripts/verify-api-docs.mjs",
67
+ "notices": "node scripts/gen-third-party-notices.mjs",
50
68
  "verify:bundle": "node scripts/verify-bundle.mjs",
51
- "pack:release": "npm run build && node scripts/package-release.mjs",
52
- "prepack": "npm run build && npm run verify:bundle",
69
+ "pack:release": "npm run notices && npm run build && node scripts/package-release.mjs",
70
+ "prepack": "npm run notices && npm run build && npm run verify:api-docs",
53
71
  "prepublishOnly": "npm run typecheck && npm run lint && npm run test && npm run build && npm run verify:bundle"
54
72
  },
55
73
  "dependencies": {
56
- "@clack/prompts": "^1.5.1",
57
- "@commander-js/extra-typings": "^15.0.0",
58
- "axios": "^1.7.9",
59
- "commander": "^15.0.0",
60
- "picocolors": "^1.1.1"
74
+ "@types/node": "^26.2.0",
75
+ "axios": "^1.7.9"
61
76
  },
62
77
  "devDependencies": {
63
- "@biomejs/biome": "^2.4.16",
64
- "@types/node": "^25.9.1",
78
+ "@biomejs/biome": "^2.5.9",
79
+ "@clack/prompts": "^1.7.0",
80
+ "@commander-js/extra-typings": "^15.0.0",
81
+ "commander": "^15.0.0",
82
+ "picocolors": "^1.1.1",
65
83
  "tsup": "^8.3.5",
66
- "tsx": "^4.19.2",
67
- "typescript": "^6.0.3",
68
- "vitest": "^4.1.8"
84
+ "tsx": "^4.23.12",
85
+ "typescript": "^7.0.2",
86
+ "vitest": "^4.1.11"
87
+ },
88
+ "overrides": {
89
+ "esbuild": "^0.28.2"
69
90
  }
70
91
  }