Skip to content

Commit 887a776

Browse files
author
heeho
committed
Initial public release
0 parents  commit 887a776

15 files changed

Lines changed: 1640 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: macos-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: astral-sh/setup-uv@v6
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.12"
18+
- name: Sync dependencies
19+
run: uv sync --extra dev
20+
- name: Run tests
21+
run: uv run --extra dev pytest
22+
- name: Compile package
23+
run: uv run python -m py_compile src/toss_browser_bridge/*.py

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
__pycache__/
3+
*.pyc
4+
.venv/
5+
dist/
6+
build/
7+
*.egg-info/
8+
.pytest_cache/
9+
10+
# Local runtime state
11+
.runtime/
12+
.playwright/
13+
14+
# Runtime artifacts
15+
token
16+
daemon.pid
17+
daemon.log

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Heeho Lim
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.

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Toss Browser Bridge
2+
3+
토스증권 웹에 로그인된 **전용 Chrome 프로필**을 브리지가 직접 소유하고, 브라우저 컨텍스트 안에서 read-only 조회를 수행하는 로컬 daemon/CLI 프로젝트다.
4+
5+
공식 토스증권 API 프로젝트가 아니다. browser-attached companion 성격의 **비공식 read-only 도구**다.
6+
7+
## 현재 지원 명령
8+
9+
- `health`
10+
- `open-login`
11+
- `account-summary`
12+
- `positions`
13+
- `completed-orders`
14+
- `quote`
15+
- `reconnect`
16+
- `shutdown`
17+
- `diagnostics`
18+
19+
## quickstart
20+
21+
```bash
22+
uv run --project . toss-bridge health
23+
uv run --project . toss-bridge open-login
24+
uv run --project . toss-bridge account-summary
25+
uv run --project . --extra dev pytest
26+
sh scripts/scrub-check.sh
27+
```
28+
29+
런타임 상태는 기본적으로 아래 경로를 사용한다.
30+
31+
- `~/Library/Application Support/toss-browser-bridge/chrome-profile`
32+
- `~/Library/Application Support/toss-browser-bridge/token`
33+
- `~/Library/Application Support/toss-browser-bridge/daemon.pid`
34+
- `~/Library/Application Support/toss-browser-bridge/daemon.log`
35+
36+
`TOSS_BRIDGE_HOME` 환경변수로 override 가능하다.
37+
기본 listen 포트는 `42194`이며, `TOSS_BRIDGE_PORT`로 override 가능하다.
38+
39+
기존 `financier-v2` 내장 bridge와 같은 머신에서 함께 돌릴 때는 포트를 분리해야 한다.
40+
41+
## 예시 출력
42+
43+
- logged out capability matrix: [examples/health-attached-but-logged-out.json](examples/health-attached-but-logged-out.json)
44+
45+
## 현재 범위
46+
47+
- read-only only
48+
- browser-attached only
49+
- Toss Securities web dependency
50+
51+
## 현재 비범위
52+
53+
- 주문/정정/취소/환전
54+
- 공식 API 안정성 보장
55+
- 헤드리스 세션 재생
56+
57+
## known limitations
58+
59+
- 토스증권 웹 구조나 내부 endpoint가 바뀌면 깨질 수 있다.
60+
- 전용 Chrome 프로필에 직접 로그인해야 한다.
61+
- `health``attached_but_logged_out`일 때는 브라우저 연결만 성공한 상태다.

SECURITY.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Security
2+
3+
## Scope
4+
5+
이 프로젝트는 로컬 전용 read-only browser bridge를 목표로 한다.
6+
7+
다음 항목은 절대 issue/PR에 첨부하지 말 것:
8+
9+
- raw cookie
10+
- raw storage-state
11+
- bearer token
12+
- raw response body
13+
- 계좌번호 원문
14+
15+
## Reporting
16+
17+
민감정보가 이미 커밋되었거나 노출될 가능성이 있으면 공개 issue 대신 비공개 채널로 먼저 알려야 한다.
18+
19+
현재는 정식 security mailbox를 두지 않았으므로, 공개 issue에는 sanitized 재현 정보만 남기는 것을 원칙으로 한다.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"ok": true,
3+
"kind": "health",
4+
"source": "toss_browser_bridge",
5+
"checked_at": "2026-04-17T02:01:30+09:00",
6+
"capability": "attached_but_logged_out",
7+
"data": {
8+
"attached": true,
9+
"current_url": "https://www.tossinvest.com/signin?redirectUrl=%2Faccount",
10+
"profile_name": "toss-bridge",
11+
"capabilities": {
12+
"browser_attached": true,
13+
"web_session_ready": false,
14+
"wts_api_ready": false,
15+
"wts_cert_api_ready": false,
16+
"account_summary_ready": false,
17+
"positions_ready": false,
18+
"completed_orders_ready": false,
19+
"quote_ready": true
20+
},
21+
"session_state": "attached_but_logged_out"
22+
},
23+
"diagnostics": {
24+
"endpoint_matrix": [
25+
{
26+
"name": "account_list",
27+
"method": "GET",
28+
"path": "/api/v1/account/list",
29+
"status_code": 401,
30+
"ok": false,
31+
"error": null
32+
},
33+
{
34+
"name": "account_overview",
35+
"method": "GET",
36+
"path": "/api/v3/my-assets/summaries/markets/all/overview",
37+
"status_code": 401,
38+
"ok": false,
39+
"error": null
40+
},
41+
{
42+
"name": "asset_sections_v2",
43+
"method": "POST",
44+
"path": "/api/v2/dashboard/asset/sections/all",
45+
"status_code": 200,
46+
"ok": true,
47+
"error": null
48+
},
49+
{
50+
"name": "completed_orders_us_probe",
51+
"method": "GET",
52+
"path": "/api/v2/trading/my-orders/markets/us/by-date/completed",
53+
"status_code": 401,
54+
"ok": false,
55+
"error": null
56+
},
57+
{
58+
"name": "quote_probe",
59+
"method": "GET",
60+
"path": "/api/v1/product/stock-prices",
61+
"status_code": 200,
62+
"ok": true,
63+
"error": null
64+
}
65+
],
66+
"last_errors": [
67+
"account_list: 401",
68+
"account_overview: 401",
69+
"completed_orders_us_probe: 401"
70+
]
71+
}
72+
}

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[project]
2+
name = "toss-browser-bridge"
3+
version = "0.1.0"
4+
description = "Unofficial read-only browser bridge for Toss Securities web"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
license = { text = "MIT" }
8+
authors = [
9+
{ name = "Heeho Lim" },
10+
]
11+
dependencies = [
12+
"playwright>=1.53.0",
13+
]
14+
15+
[project.optional-dependencies]
16+
dev = [
17+
"pytest>=8.4.0",
18+
]
19+
20+
[project.scripts]
21+
toss-bridge = "toss_browser_bridge.cli:main"
22+
toss-bridge-daemon = "toss_browser_bridge.daemon:main"
23+
24+
[build-system]
25+
requires = ["hatchling"]
26+
build-backend = "hatchling.build"
27+
28+
[tool.hatch.build.targets.wheel]
29+
packages = ["src/toss_browser_bridge"]

scripts/scrub-check.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
ROOT_DIR="$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)"
5+
cd "$ROOT_DIR"
6+
7+
echo "Running scrub checks in $ROOT_DIR"
8+
9+
TRACKED_FILES="$(mktemp)"
10+
trap 'rm -f "$TRACKED_FILES"' EXIT HUP INT TERM
11+
git ls-files > "$TRACKED_FILES"
12+
13+
if [ -s "$TRACKED_FILES" ]; then
14+
if xargs rg -n \
15+
-e '/Users/heeho/' \
16+
-e '44258118' \
17+
-e 'Application Support/financier-v2' \
18+
-e 'financier-v2/scripts/toss-bridge' \
19+
-e 'accountNo":[0-9]' \
20+
-e 'XSRF-TOKEN=[^"]{12,}' \
21+
-e 'browserSessionId[^[:space:]]{8,}' \
22+
-e 'WTS-BROWSER-TAB-ID[^[:space:]]{8,}' \
23+
< "$TRACKED_FILES"; then
24+
echo "Scrub check failed"
25+
exit 1
26+
fi
27+
fi
28+
29+
if git ls-files | grep -E 'chrome-profile|token$|daemon\.pid$|daemon\.log$|playwright-storage-state' >/dev/null; then
30+
echo "Scrub check failed: runtime artifact tracked"
31+
exit 1
32+
fi
33+
34+
echo "Scrub check passed"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__all__ = ["__version__"]
2+
3+
__version__ = "0.1.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from toss_browser_bridge.cli import main
2+
3+
4+
if __name__ == "__main__":
5+
main()

0 commit comments

Comments
 (0)