Skip to content

Commit 9d344cb

Browse files
✨ Adds back cli tool (#286)
- Adds polyfill to suppress screensaver fails - Simplifies ability to set attributes in TDF3Encrypt (no longer require attribute objects with KAS url) - Removes ability to pass in an output stream to TDF3Client.encrypt
1 parent 091d5e3 commit 9d344cb

29 files changed

+9091
-10262
lines changed

.github/workflows/build.yaml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,41 @@ jobs:
8282
- run: npm run lint
8383
- run: npm pack
8484

85+
cli:
86+
needs:
87+
- lib
88+
runs-on: ubuntu-latest
89+
defaults:
90+
run:
91+
working-directory: ./cli
92+
timeout-minutes: 5
93+
steps:
94+
- uses: actions/checkout@v4
95+
- uses: actions/setup-node@v4
96+
with:
97+
node-version: '20'
98+
cache: 'npm'
99+
cache-dependency-path: './cli/package-lock.json'
100+
- uses: actions/download-artifact@v4
101+
with:
102+
name: opentdf-client-lib
103+
path: lib/
104+
- run: npm uninstall @opentdf/client && npm ci && npm i ../lib/opentdf-client-*.tgz
105+
- run: npm test
106+
- run: npm audit --omit dev && npm audit --audit-level high
107+
- run: npm run license-check
108+
- run: npm run lint
109+
- run: npm pack
110+
- name: Setup BATS
111+
uses: mig4/setup-bats@v1
112+
with:
113+
bats-version: 1.2.1
114+
- run: bats bin/opentdf.bats
115+
- uses: actions/upload-artifact@v4
116+
with:
117+
name: opentdf-cli
118+
path: ./cli/opentdf-cli-*.tgz
119+
85120
web-app:
86121
needs:
87122
- lib
@@ -126,6 +161,8 @@ jobs:
126161
127162
backend-roundtrip:
128163
needs:
164+
- cli
165+
- lib
129166
- web-app
130167
runs-on: ubuntu-latest
131168
defaults:
@@ -143,6 +180,10 @@ jobs:
143180
with:
144181
name: opentdf-client-lib
145182
path: lib/
183+
- uses: actions/download-artifact@v4
184+
with:
185+
name: opentdf-cli
186+
path: cli/
146187
- uses: yokawasa/[email protected]
147188
with:
148189
setup-tools: |
@@ -174,6 +215,7 @@ jobs:
174215
deliver-ghp:
175216
needs:
176217
- lib
218+
- cli
177219
- web-app
178220
- scripts
179221
- backend-roundtrip
@@ -222,9 +264,8 @@ jobs:
222264
${{ steps.guess-build-metadata.outputs.DIST_TAG }}
223265
env:
224266
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
225-
- run:
226-
echo "- [Client
227-
Library](https://github.com/opentdf/client-web/pkgs/npm/client)">>$GITHUB_STEP_SUMMARY
267+
- run: echo "- [Client Library](https://github.com/opentdf/client-web/pkgs/npm/client)">>$GITHUB_STEP_SUMMARY
268+
- run: echo "- [Command Line Tool](https://github.com/opentdf/client-web/pkgs/npm/cli)">>$GITHUB_STEP_SUMMARY
228269
- name: trigger xtest
229270
run: >-
230271
curl -XPOST -u "virtru-cloudnative:${{secrets.PERSONAL_ACCESS_TOKEN}}"
@@ -235,7 +276,7 @@ jobs:
235276
env:
236277
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
237278
- name: Publish documentation to gh-pages
238-
uses: JamesIves/github-pages-deploy-action@v4.4.1
279+
uses: JamesIves/github-pages-deploy-action@v4.6.0
239280
with:
240281
branch: gh-pages
241282
folder: lib/dist/docs
@@ -262,11 +303,10 @@ jobs:
262303
env:
263304
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
264305
- run: >-
265-
echo "- [Client Library](https://www.npmjs.com/package/@opentdf/client/v/${{
266-
needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
306+
echo "- [Client Library](https://www.npmjs.com/package/@opentdf/client/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
307+
- run: >-
308+
echo "- [Remote Store](https://www.npmjs.com/package/@opentdf/remote-store/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
267309
- run: >-
268-
echo "- [Remote Store](https://www.npmjs.com/package/@opentdf/remote-store/v/${{
269-
needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
310+
echo "- [Command Line Tool](https://www.npmjs.com/package/@opentdf/cli/v/${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
270311
- run: >-
271-
echo "- [unpkg](https://unpkg.com/browse/@opentdf/client@${{
272-
needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY
312+
echo "- [unpkg](https://unpkg.com/browse/@opentdf/client@${{ needs.deliver-ghp.outputs.FULL_VERSION }})">>$GITHUB_STEP_SUMMARY

.github/workflows/format.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
3030
- name: Suggest user signoff
3131
if: steps.auto-commit.outputs.changes_detected == 'true'
32-
uses: actions/github-script@v6
32+
uses: actions/github-script@v7
3333
with:
3434
github-token: ${{ secrets.GITHUB_TOKEN }}
3535
script: |

.github/workflows/large-tests.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,36 @@ jobs:
3232
name: opentdf-client-lib
3333
path: ./lib/opentdf-client-*.tgz
3434

35+
cli:
36+
needs:
37+
- lib
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: ./cli
42+
timeout-minutes: 5
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
cache: 'npm'
49+
cache-dependency-path: './cli/package-lock.json'
50+
- uses: actions/download-artifact@v4
51+
with:
52+
name: opentdf-client-lib
53+
path: lib/
54+
- run: npm uninstall @opentdf/client && npm ci && npm i ../lib/opentdf-client-*.tgz
55+
- run: npm test
56+
- run: npm audit --omit dev --audit-level moderate
57+
- run: npm run license-check
58+
- run: npm run lint
59+
- run: npm pack
60+
- uses: actions/upload-artifact@v4
61+
with:
62+
name: opentdf-cli
63+
path: ./cli/opentdf-cli-*.tgz
64+
3565
web-app:
3666
needs:
3767
- lib
@@ -61,7 +91,8 @@ jobs:
6191

6292
backend-roundtrip:
6393
needs:
64-
- web-app
94+
- cli
95+
- lib
6596
runs-on: ubuntu-latest
6697
defaults:
6798
run:
@@ -78,10 +109,14 @@ jobs:
78109
with:
79110
name: opentdf-client-lib
80111
path: lib/
112+
- uses: actions/download-artifact@v4
113+
with:
114+
name: opentdf-cli
115+
path: cli
81116
- name: Git clone backend
82117
run: |
83118
git clone https://github.com/opentdf/opentdf.git
84-
- uses: yokawasa/action-setup-kube-tools@v0.9.2
119+
- uses: yokawasa/action-setup-kube-tools@v0.11.1
85120
with:
86121
setup-tools: |
87122
kubectl

.github/workflows/publish-to.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ npm publish --access public --tag "$t"
2020
# Wait for npm publish to go through...
2121
sleep 5
2222

23-
cd ../remote-store
23+
for x in remote-store cli; do
24+
cd "../$x"
2425

25-
npm version --no-git-tag-version --allow-same-version "$v"
26-
npm uninstall "@opentdf/client"
27-
npm install "@opentdf/client@$v"
28-
npm publish --access public --tag "$t"
26+
npm version --no-git-tag-version --allow-same-version "$v"
27+
npm uninstall "@opentdf/client"
28+
npm install "@opentdf/client@$v"
29+
npm publish --access public --tag "$t"
30+
done
2931

3032
if [[ "$GITHUB_STEP_SUMMARY" ]]; then
3133
echo "### Published ${v} (${t})" >>"$GITHUB_STEP_SUMMARY"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
set -exuo pipefail
3+
4+
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
5+
6+
cd "$APP_DIR"
7+
8+
counter=0
9+
10+
_nano_test() {
11+
counter=$((counter + 1))
12+
plain="./sample-${counter}.txt"
13+
echo "Hello World ${counter}" >"./${plain}"
14+
npx "$1" --log-level DEBUG \
15+
--kasEndpoint http://localhost:65432/api/kas \
16+
--oidcEndpoint http://localhost:65432/auth/realms/tdf \
17+
--auth tdf-client:123-456 \
18+
--output sample.txt.ntdf \
19+
encrypt "${plain}" \
20+
--attributes https://example.com/attr/Classification/value/S,https://example.com/attr/COI/value/PRX
21+
22+
[ -f sample.txt.ntdf ]
23+
24+
npx "$2" --log-level DEBUG \
25+
--kasEndpoint http://localhost:65432/api/kas \
26+
--oidcEndpoint http://localhost:65432/auth/realms/tdf \
27+
--auth tdf-client:123-456 \
28+
--output sample_out.txt \
29+
decrypt sample.txt.ntdf
30+
31+
[ -f sample_out.txt ] && diff "${plain}" sample_out.txt
32+
33+
echo "Roundtrip nanotdf $1 -> $2 successful!"
34+
rm -f "${plain}" sample.txt.ntdf sample_out.txt
35+
}
36+
37+
_nano_test @opentdf/cli @opentdf/cli
38+
39+
_tdf3_test() {
40+
counter=$((counter + 1))
41+
plain="./sample-${counter}.txt"
42+
echo "Hello World ${counter}" >"${plain}"
43+
npx "$1" --log-level DEBUG \
44+
--kasEndpoint http://localhost:65432/api/kas \
45+
--oidcEndpoint http://localhost:65432/auth/realms/tdf \
46+
--auth tdf-client:123-456 \
47+
--output sample.txt.tdf \
48+
encrypt "${plain}" \
49+
--containerType tdf3 \
50+
--attributes https://example.com/attr/Classification/value/S,https://example.com/attr/COI/value/PRX
51+
52+
[ -f sample.txt.tdf ]
53+
54+
npx "$2" --log-level DEBUG \
55+
--kasEndpoint http://localhost:65432/api/kas \
56+
--oidcEndpoint http://localhost:65432/auth/realms/tdf \
57+
--auth tdf-client:123-456 \
58+
--output sample_out.txt \
59+
--containerType tdf3 \
60+
decrypt sample.txt.tdf
61+
62+
[ -f sample_out.txt ] && diff "${plain}" sample_out.txt
63+
64+
echo "Roundtrip tdf3 $1 -> $2 successful!"
65+
rm -f "${plain}" sample.txt.tdf sample_out.txt
66+
}
67+
68+
_tdf3_test @opentdf/cli @opentdf/cli

0 commit comments

Comments
 (0)