tripwire-server 0.1.0__tar.gz
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.
- tripwire_server-0.1.0/.github/workflows/ci.yml +56 -0
- tripwire_server-0.1.0/.github/workflows/release.yml +142 -0
- tripwire_server-0.1.0/.gitignore +7 -0
- tripwire_server-0.1.0/LICENSE +21 -0
- tripwire_server-0.1.0/PKG-INFO +121 -0
- tripwire_server-0.1.0/README.md +106 -0
- tripwire_server-0.1.0/RELEASING.md +35 -0
- tripwire_server-0.1.0/pyproject.toml +26 -0
- tripwire_server-0.1.0/scripts/check-spec-sync.sh +55 -0
- tripwire_server-0.1.0/spec/LICENSE +21 -0
- tripwire_server-0.1.0/spec/README.md +129 -0
- tripwire_server-0.1.0/spec/fixtures/errors/invalid-api-key.json +10 -0
- tripwire_server-0.1.0/spec/fixtures/errors/missing-api-key.json +10 -0
- tripwire_server-0.1.0/spec/fixtures/errors/not-found.json +10 -0
- tripwire_server-0.1.0/spec/fixtures/errors/validation-error.json +21 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/fingerprints/detail.json +40 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/fingerprints/list.json +31 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/sessions/detail.json +47 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/sessions/list.json +33 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/api-key-create.json +18 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/api-key-list.json +23 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/api-key-revoke.json +3 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/api-key-rotate.json +18 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/team-create.json +11 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/team-update.json +11 -0
- tripwire_server-0.1.0/spec/fixtures/public-api/teams/team.json +11 -0
- tripwire_server-0.1.0/spec/fixtures/sealed-token/invalid.json +4 -0
- tripwire_server-0.1.0/spec/fixtures/sealed-token/vector.v1.json +41 -0
- tripwire_server-0.1.0/spec/openapi.json +1435 -0
- tripwire_server-0.1.0/spec/sealed-token.md +95 -0
- tripwire_server-0.1.0/tests/test_client.py +220 -0
- tripwire_server-0.1.0/tests/test_contract.py +48 -0
- tripwire_server-0.1.0/tests/test_helpers.py +11 -0
- tripwire_server-0.1.0/tests/test_live.py +103 -0
- tripwire_server-0.1.0/tests/test_sealed_token.py +36 -0
- tripwire_server-0.1.0/tripwire_server/__init__.py +38 -0
- tripwire_server-0.1.0/tripwire_server/client.py +457 -0
- tripwire_server-0.1.0/tripwire_server/errors.py +26 -0
- tripwire_server-0.1.0/tripwire_server/sealed_token.py +130 -0
- tripwire_server-0.1.0/tripwire_server/types.py +181 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- codex/**
|
|
8
|
+
pull_request:
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
- run: python -m pip install --upgrade pip build
|
|
23
|
+
- run: python -m pip install -e .
|
|
24
|
+
- run: python -m unittest tests.test_client tests.test_contract tests.test_sealed_token
|
|
25
|
+
- run: python -m build
|
|
26
|
+
|
|
27
|
+
spec-sync:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
- name: Check synced spec
|
|
32
|
+
run: bash ./scripts/check-spec-sync.sh
|
|
33
|
+
|
|
34
|
+
live-smoke:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
needs: [test, spec-sync]
|
|
37
|
+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
|
|
38
|
+
env:
|
|
39
|
+
TRIPWIRE_LIVE_SMOKE: "1"
|
|
40
|
+
TRIPWIRE_SMOKE_SECRET_KEY: ${{ secrets.TRIPWIRE_SMOKE_SECRET_KEY }}
|
|
41
|
+
TRIPWIRE_SMOKE_TEAM_ID: ${{ secrets.TRIPWIRE_SMOKE_TEAM_ID }}
|
|
42
|
+
TRIPWIRE_SMOKE_BASE_URL: ${{ secrets.TRIPWIRE_SMOKE_BASE_URL }}
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- uses: actions/setup-python@v5
|
|
46
|
+
with:
|
|
47
|
+
python-version: "3.12"
|
|
48
|
+
- name: Require smoke secrets
|
|
49
|
+
if: ${{ env.TRIPWIRE_SMOKE_SECRET_KEY == '' || env.TRIPWIRE_SMOKE_TEAM_ID == '' }}
|
|
50
|
+
run: |
|
|
51
|
+
echo "TRIPWIRE_SMOKE_SECRET_KEY and TRIPWIRE_SMOKE_TEAM_ID are required for live smoke tests."
|
|
52
|
+
exit 1
|
|
53
|
+
- run: python -m pip install --upgrade pip
|
|
54
|
+
- run: python -m pip install -e .
|
|
55
|
+
- name: Run live smoke suite
|
|
56
|
+
run: python -m unittest tests.test_live
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
confirm_version:
|
|
7
|
+
description: Version in pyproject.toml to release
|
|
8
|
+
required: true
|
|
9
|
+
type: string
|
|
10
|
+
dry_run:
|
|
11
|
+
description: Build and verify without tagging or publishing
|
|
12
|
+
required: true
|
|
13
|
+
default: true
|
|
14
|
+
type: boolean
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
prepare:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
outputs:
|
|
23
|
+
version: ${{ steps.version.outputs.version }}
|
|
24
|
+
tag: ${{ steps.version.outputs.tag }}
|
|
25
|
+
commit_sha: ${{ steps.commit.outputs.sha }}
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
with:
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
|
|
31
|
+
- uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: "3.12"
|
|
34
|
+
|
|
35
|
+
- id: commit
|
|
36
|
+
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
37
|
+
|
|
38
|
+
- id: version
|
|
39
|
+
run: |
|
|
40
|
+
VERSION=$(python - <<'PY'
|
|
41
|
+
import pathlib
|
|
42
|
+
import tomllib
|
|
43
|
+
|
|
44
|
+
with pathlib.Path("pyproject.toml").open("rb") as handle:
|
|
45
|
+
data = tomllib.load(handle)
|
|
46
|
+
print(data["project"]["version"])
|
|
47
|
+
PY
|
|
48
|
+
)
|
|
49
|
+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
50
|
+
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
|
|
51
|
+
|
|
52
|
+
- name: Validate release inputs
|
|
53
|
+
env:
|
|
54
|
+
EXPECTED_VERSION: ${{ inputs.confirm_version }}
|
|
55
|
+
ACTUAL_VERSION: ${{ steps.version.outputs.version }}
|
|
56
|
+
DRY_RUN: ${{ inputs.dry_run }}
|
|
57
|
+
REF_NAME: ${{ github.ref_name }}
|
|
58
|
+
run: |
|
|
59
|
+
if [ "$EXPECTED_VERSION" != "$ACTUAL_VERSION" ]; then
|
|
60
|
+
echo "Expected version $EXPECTED_VERSION, found $ACTUAL_VERSION."
|
|
61
|
+
exit 1
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
if [ "$DRY_RUN" != "true" ] && [ "$REF_NAME" != "main" ]; then
|
|
65
|
+
echo "Real releases must run from main."
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
- name: Ensure release tag is new
|
|
70
|
+
env:
|
|
71
|
+
TAG: ${{ steps.version.outputs.tag }}
|
|
72
|
+
run: |
|
|
73
|
+
git fetch --tags --force
|
|
74
|
+
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
|
|
75
|
+
echo "Tag $TAG already exists."
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
- run: python -m pip install --upgrade pip build
|
|
80
|
+
- run: python -m pip install -e .
|
|
81
|
+
- run: python -m unittest tests.test_client tests.test_contract tests.test_sealed_token
|
|
82
|
+
- run: python -m build
|
|
83
|
+
|
|
84
|
+
- uses: actions/upload-artifact@v4
|
|
85
|
+
with:
|
|
86
|
+
name: release-artifacts
|
|
87
|
+
path: dist/*
|
|
88
|
+
if-no-files-found: error
|
|
89
|
+
retention-days: 7
|
|
90
|
+
|
|
91
|
+
publish:
|
|
92
|
+
if: ${{ !inputs.dry_run }}
|
|
93
|
+
needs: prepare
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
environment: release
|
|
96
|
+
permissions:
|
|
97
|
+
contents: write
|
|
98
|
+
id-token: write
|
|
99
|
+
env:
|
|
100
|
+
GH_TOKEN: ${{ github.token }}
|
|
101
|
+
steps:
|
|
102
|
+
- uses: actions/checkout@v4
|
|
103
|
+
with:
|
|
104
|
+
fetch-depth: 0
|
|
105
|
+
ref: ${{ needs.prepare.outputs.commit_sha }}
|
|
106
|
+
|
|
107
|
+
- uses: actions/download-artifact@v4
|
|
108
|
+
with:
|
|
109
|
+
name: release-artifacts
|
|
110
|
+
path: dist
|
|
111
|
+
|
|
112
|
+
- name: Ensure release is still new
|
|
113
|
+
env:
|
|
114
|
+
TAG: ${{ needs.prepare.outputs.tag }}
|
|
115
|
+
run: |
|
|
116
|
+
git fetch --tags --force
|
|
117
|
+
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
|
|
118
|
+
echo "Tag $TAG already exists."
|
|
119
|
+
exit 1
|
|
120
|
+
fi
|
|
121
|
+
if gh release view "$TAG" >/dev/null 2>&1; then
|
|
122
|
+
echo "GitHub release $TAG already exists."
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
- name: Create and push release tag
|
|
127
|
+
env:
|
|
128
|
+
TAG: ${{ needs.prepare.outputs.tag }}
|
|
129
|
+
run: |
|
|
130
|
+
git config user.name "github-actions[bot]"
|
|
131
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
132
|
+
git tag -a "$TAG" -m "Release $TAG"
|
|
133
|
+
git push origin "$TAG"
|
|
134
|
+
|
|
135
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
136
|
+
with:
|
|
137
|
+
packages-dir: dist
|
|
138
|
+
|
|
139
|
+
- name: Create GitHub release
|
|
140
|
+
env:
|
|
141
|
+
TAG: ${{ needs.prepare.outputs.tag }}
|
|
142
|
+
run: gh release create "$TAG" dist/* --title "$TAG" --generate-notes --verify-tag
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ABXY Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tripwire-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Tripwire Python server SDK
|
|
5
|
+
Project-URL: Homepage, https://github.com/abxy-labs/tripwire-server-python
|
|
6
|
+
Project-URL: Repository, https://github.com/abxy-labs/tripwire-server-python
|
|
7
|
+
Project-URL: Issues, https://github.com/abxy-labs/tripwire-server-python/issues
|
|
8
|
+
Author: ABXY Labs
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Requires-Dist: cryptography<47,>=42
|
|
13
|
+
Requires-Dist: httpx<1,>=0.27
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# Tripwire Python Library
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
The Tripwire Python library provides convenient access to the Tripwire API from applications written in Python. It includes a synchronous client for Sessions, Fingerprints, Teams, Team API key management, and sealed token verification.
|
|
23
|
+
|
|
24
|
+
The library also provides:
|
|
25
|
+
|
|
26
|
+
- a fast configuration path using `TRIPWIRE_SECRET_KEY`
|
|
27
|
+
- iterator helpers for cursor-based pagination
|
|
28
|
+
- structured API errors and built-in sealed token verification
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
See the [Tripwire docs](https://tripwirejs.com/docs) and [API reference](https://tripwirejs.com/docs/api-reference/introduction).
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
You don't need this source code unless you want to modify the package. If you just want to use the package, run:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install tripwire-server
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
- Python 3.10+
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
The library needs to be configured with your account's secret key. Set `TRIPWIRE_SECRET_KEY` in your environment or pass `secret_key` directly:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from tripwire_server import Tripwire
|
|
52
|
+
|
|
53
|
+
client = Tripwire(secret_key="sk_live_...")
|
|
54
|
+
|
|
55
|
+
page = client.sessions.list(verdict="bot", limit=25)
|
|
56
|
+
session = client.sessions.get("sid_123")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Sealed token verification
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from tripwire_server import safe_verify_tripwire_token
|
|
63
|
+
|
|
64
|
+
result = safe_verify_tripwire_token(
|
|
65
|
+
sealed_token,
|
|
66
|
+
"sk_live_...",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if result.ok:
|
|
70
|
+
print(result.data.verdict, result.data.score)
|
|
71
|
+
else:
|
|
72
|
+
print(result.error)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Pagination
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
for session in client.sessions.iter(search="signup"):
|
|
79
|
+
print(session.id, session.latest_result.verdict)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Fingerprints
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
page = client.fingerprints.list(sort="seen_count")
|
|
86
|
+
fingerprint = client.fingerprints.get("vis_123")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Teams
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
team = client.teams.get("team_123")
|
|
93
|
+
updated = client.teams.update("team_123", name="New Name")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Team API keys
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
created = client.teams.api_keys.create(
|
|
100
|
+
"team_123",
|
|
101
|
+
name="Production",
|
|
102
|
+
allowed_origins=["https://example.com"],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
client.teams.api_keys.revoke("team_123", created.id)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Error handling
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from tripwire_server import TripwireApiError
|
|
112
|
+
|
|
113
|
+
try:
|
|
114
|
+
client.sessions.list(limit=999)
|
|
115
|
+
except TripwireApiError as error:
|
|
116
|
+
print(error.status, error.code, error.message)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Support
|
|
120
|
+
|
|
121
|
+
If you need help integrating Tripwire, start with [tripwirejs.com/docs](https://tripwirejs.com/docs).
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Tripwire Python Library
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
The Tripwire Python library provides convenient access to the Tripwire API from applications written in Python. It includes a synchronous client for Sessions, Fingerprints, Teams, Team API key management, and sealed token verification.
|
|
8
|
+
|
|
9
|
+
The library also provides:
|
|
10
|
+
|
|
11
|
+
- a fast configuration path using `TRIPWIRE_SECRET_KEY`
|
|
12
|
+
- iterator helpers for cursor-based pagination
|
|
13
|
+
- structured API errors and built-in sealed token verification
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
See the [Tripwire docs](https://tripwirejs.com/docs) and [API reference](https://tripwirejs.com/docs/api-reference/introduction).
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
You don't need this source code unless you want to modify the package. If you just want to use the package, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install tripwire-server
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- Python 3.10+
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
The library needs to be configured with your account's secret key. Set `TRIPWIRE_SECRET_KEY` in your environment or pass `secret_key` directly:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from tripwire_server import Tripwire
|
|
37
|
+
|
|
38
|
+
client = Tripwire(secret_key="sk_live_...")
|
|
39
|
+
|
|
40
|
+
page = client.sessions.list(verdict="bot", limit=25)
|
|
41
|
+
session = client.sessions.get("sid_123")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Sealed token verification
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from tripwire_server import safe_verify_tripwire_token
|
|
48
|
+
|
|
49
|
+
result = safe_verify_tripwire_token(
|
|
50
|
+
sealed_token,
|
|
51
|
+
"sk_live_...",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if result.ok:
|
|
55
|
+
print(result.data.verdict, result.data.score)
|
|
56
|
+
else:
|
|
57
|
+
print(result.error)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Pagination
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
for session in client.sessions.iter(search="signup"):
|
|
64
|
+
print(session.id, session.latest_result.verdict)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Fingerprints
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
page = client.fingerprints.list(sort="seen_count")
|
|
71
|
+
fingerprint = client.fingerprints.get("vis_123")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Teams
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
team = client.teams.get("team_123")
|
|
78
|
+
updated = client.teams.update("team_123", name="New Name")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Team API keys
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
created = client.teams.api_keys.create(
|
|
85
|
+
"team_123",
|
|
86
|
+
name="Production",
|
|
87
|
+
allowed_origins=["https://example.com"],
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
client.teams.api_keys.revoke("team_123", created.id)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Error handling
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from tripwire_server import TripwireApiError
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
client.sessions.list(limit=999)
|
|
100
|
+
except TripwireApiError as error:
|
|
101
|
+
print(error.status, error.code, error.message)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Support
|
|
105
|
+
|
|
106
|
+
If you need help integrating Tripwire, start with [tripwirejs.com/docs](https://tripwirejs.com/docs).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Releasing `tripwire-server`
|
|
2
|
+
|
|
3
|
+
This repository uses a manual `release.yml` workflow. Versions are independent from the other Tripwire server SDKs.
|
|
4
|
+
|
|
5
|
+
## Before the first real release
|
|
6
|
+
|
|
7
|
+
Configure these GitHub and registry settings:
|
|
8
|
+
|
|
9
|
+
1. Create a protected GitHub environment named `release` with required reviewer approval.
|
|
10
|
+
2. Create the `tripwire-server` project on PyPI if it does not already exist.
|
|
11
|
+
3. Add a pending PyPI trusted publisher for:
|
|
12
|
+
- repository: `abxy-labs/tripwire-server-python`
|
|
13
|
+
- workflow: `.github/workflows/release.yml`
|
|
14
|
+
- environment: `release`
|
|
15
|
+
|
|
16
|
+
## Release flow
|
|
17
|
+
|
|
18
|
+
1. Bump `pyproject.toml` to the target version in a pull request.
|
|
19
|
+
2. Merge the version bump to `main`.
|
|
20
|
+
3. Open GitHub Actions and run `Release`.
|
|
21
|
+
4. Set `confirm_version` to the exact `pyproject.toml` version.
|
|
22
|
+
5. Run a `dry_run=true` release first.
|
|
23
|
+
6. Re-run with `dry_run=false` once the dry run looks correct and the `release` environment approval is in place.
|
|
24
|
+
|
|
25
|
+
## What the workflow does
|
|
26
|
+
|
|
27
|
+
- reads the release version from `pyproject.toml`
|
|
28
|
+
- reruns the equivalent of the repo checks
|
|
29
|
+
- builds the wheel and source distribution with `python -m build`
|
|
30
|
+
- on real releases:
|
|
31
|
+
- creates tag `vX.Y.Z`
|
|
32
|
+
- publishes `tripwire-server` to PyPI with trusted publishing
|
|
33
|
+
- creates a GitHub Release with the built artifacts attached
|
|
34
|
+
|
|
35
|
+
GitHub Release notes use autogenerated notes. There is no prerelease channel in this phase.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tripwire-server"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Tripwire Python server SDK"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "ABXY Labs" }
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"cryptography>=42,<47",
|
|
17
|
+
"httpx>=0.27,<1"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/abxy-labs/tripwire-server-python"
|
|
22
|
+
Repository = "https://github.com/abxy-labs/tripwire-server-python"
|
|
23
|
+
Issues = "https://github.com/abxy-labs/tripwire-server-python/issues"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel]
|
|
26
|
+
packages = ["tripwire_server"]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
SPEC_DIR="${ROOT_DIR}/spec"
|
|
6
|
+
SPEC_REPO="abxy-labs/tripwire-server-sdk-spec"
|
|
7
|
+
|
|
8
|
+
if [[ ! -d "${SPEC_DIR}" ]]; then
|
|
9
|
+
echo "Local spec/ directory is missing."
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
if [[ -n "${TRIPWIRE_SDK_SPEC_DIR:-}" ]]; then
|
|
14
|
+
SOURCE_DIR="${TRIPWIRE_SDK_SPEC_DIR%/}"
|
|
15
|
+
if [[ ! -d "${SOURCE_DIR}" ]]; then
|
|
16
|
+
echo "TRIPWIRE_SDK_SPEC_DIR does not exist: ${SOURCE_DIR}"
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
diff -ru "${SOURCE_DIR}" "${SPEC_DIR}"
|
|
21
|
+
echo "Local spec/ matches ${SOURCE_DIR}."
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if [[ -n "${TRIPWIRE_MAIN_REPO_DIR:-}" ]]; then
|
|
26
|
+
SOURCE_DIR="${TRIPWIRE_MAIN_REPO_DIR%/}/sdk-spec/server"
|
|
27
|
+
if [[ ! -d "${SOURCE_DIR}" ]]; then
|
|
28
|
+
echo "TRIPWIRE_MAIN_REPO_DIR does not contain sdk-spec/server: ${SOURCE_DIR}"
|
|
29
|
+
exit 1
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
diff -ru "${SOURCE_DIR}" "${SPEC_DIR}"
|
|
33
|
+
echo "Local spec/ matches ${SOURCE_DIR}."
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
TMP_DIR="$(mktemp -d)"
|
|
38
|
+
trap 'rm -rf "${TMP_DIR}"' EXIT
|
|
39
|
+
|
|
40
|
+
ARCHIVE_PATH="${TMP_DIR}/tripwire-server-sdk-spec.tar.gz"
|
|
41
|
+
curl -fsSL \
|
|
42
|
+
-H "Accept: application/vnd.github+json" \
|
|
43
|
+
"https://api.github.com/repos/${SPEC_REPO}/tarball/main" \
|
|
44
|
+
-o "${ARCHIVE_PATH}"
|
|
45
|
+
|
|
46
|
+
tar -xzf "${ARCHIVE_PATH}" -C "${TMP_DIR}"
|
|
47
|
+
|
|
48
|
+
SOURCE_DIR="$(find "${TMP_DIR}" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
|
|
49
|
+
if [[ -z "${SOURCE_DIR}" ]]; then
|
|
50
|
+
echo "Could not locate the extracted ${SPEC_REPO} archive."
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
diff -ru "${SOURCE_DIR}" "${SPEC_DIR}"
|
|
55
|
+
echo "Local spec/ matches the public server SDK spec source of truth."
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ABXY Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|