bydev 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.
@@ -0,0 +1,52 @@
1
+ # 출시 — 공개 거울 developedby-dev/sdk-python (ADR-0050). 원천은 모노레포 sdks/python/.github/workflows/release.yml — 거울에서 고치지 않는다.
2
+ # 판 태그(v1.0.0)를 밀면 짓고 시험한 꾸러미를, 환경 release에서 대표가 승인한 뒤 PyPI 신뢰 게시(OIDC — PEP 740 증명은 자동)로 올린다.
3
+ # 손으로 돌리면(workflow_dispatch) 짓기 · 시험만 한다. 순서는 모노레포 docs/runbooks/sdk-release.md
4
+ name: release
5
+ on:
6
+ push:
7
+ tags: ["v*.*.*"]
8
+ workflow_dispatch: {}
9
+ permissions:
10
+ contents: read
11
+ concurrency:
12
+ group: release
13
+ cancel-in-progress: false
14
+ defaults:
15
+ run:
16
+ shell: bash
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-24.04
20
+ steps:
21
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
22
+ with:
23
+ persist-credentials: false
24
+ - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2
25
+ - run: uv run --frozen ruff check .
26
+ - run: uv run --frozen mypy
27
+ - run: uv run --frozen pytest -q
28
+ - run: uv build
29
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
30
+ with:
31
+ name: dist
32
+ path: dist/
33
+ if-no-files-found: error
34
+ publish:
35
+ needs: build
36
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
37
+ runs-on: ubuntu-24.04
38
+ environment: release
39
+ permissions:
40
+ contents: read
41
+ id-token: write
42
+ steps:
43
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
44
+ with:
45
+ name: dist
46
+ path: dist/
47
+ - name: 태그와 꾸러미 판이 같은지
48
+ env:
49
+ TAG: ${{ github.ref_name }}
50
+ run: ls "dist/bydev-${TAG#v}-py3-none-any.whl" "dist/bydev-${TAG#v}.tar.gz"
51
+ - name: 게시 (신뢰 게시 · 증명)
52
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
bydev-0.1.0/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .venv/
2
+ __pycache__/
3
+ .pytest_cache/
4
+ .mypy_cache/
5
+ .ruff_cache/
6
+ dist/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 한비트 주식회사
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.
bydev-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.5
2
+ Name: bydev
3
+ Version: 0.1.0
4
+ Summary: 데브 라이선스 API 공식 Python SDK — 디바이스 로그인 · 토큰 회전 · 세션 리스 · licenseToken 검증 · 업데이트 확인 · 판매자 서버 도우미
5
+ Project-URL: Homepage, https://developedby.dev/sell/docs
6
+ Project-URL: Repository, https://github.com/developedby-dev/sdk-python
7
+ Author: 한비트 주식회사
8
+ License-Expression: MIT OR Apache-2.0
9
+ License-File: LICENSE-APACHE
10
+ License-File: LICENSE-MIT
11
+ Keywords: bydev,device-flow,license,licensing,oauth
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: cryptography>=44
21
+ Provides-Extra: keyring
22
+ Requires-Dist: keyring>=25; extra == 'keyring'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # 데브 SDK: Python
26
+
27
+ 데브 라이선스 API의 공식 Python SDK입니다. PySide, Tkinter, wxPython으로 만든 데스크톱 앱과 판매자 서버에서 씁니다.
28
+
29
+ 의존성은 Ed25519 처리에 쓰는
30
+ `cryptography` 하나뿐입니다. HTTP는 표준 `urllib`, JSON은 표준 `json`으로 처리합니다.
31
+
32
+ 모든 언어의 SDK가 함께 따르는 [공통 동작 명세](https://github.com/developedby-dev/sdk-spec/blob/main/spec/README.md)대로
33
+ 동작하고, [적합성 시험 시나리오](https://github.com/developedby-dev/sdk-spec/tree/main/conformance/scenarios)를 모두 통과합니다.
34
+
35
+ | 지원 | 버전 |
36
+ |---|---|
37
+ | 동작 명세 | 1.2.0 |
38
+ | API | v1 |
39
+ | Python | 3.11 이상 |
40
+ | 운영체제 | Windows, macOS, Linux |
41
+
42
+ 패키지 이름은 `bydev`입니다. 지금 PyPI에 있는 0.x 판은 이름을 먼저 등록하려고 낸 미리보기입니다. 1.0.0은 서비스 오픈과 함께 내며, 그 전에는
43
+ 호환되지 않는 변경이 있을 수 있습니다. 판매하는 앱에는 1.0.0 이상을 써 주세요.
44
+
45
+ ## 빠른 시작
46
+
47
+ 이 SDK는 **블로킹 API**입니다. UI 스레드에서 부르지 말고 작업 스레드에서 호출해 주세요.
48
+
49
+ asyncio 앱에서는 `bydev.aio.AsyncLicenseClient`를 쓰면 됩니다.
50
+ 같은 클라이언트를 `asyncio.to_thread`로 감싼 것입니다.
51
+
52
+ ```python
53
+ from bydev import Active, AppInfo, Config, Degraded, LicenseClient, Locked, NeedsDecision, Ports, Scope
54
+ from bydev import platform
55
+
56
+ client_id = "cli_01J9M0Y6X4N3Q8ZD5R2KT7VCPW" # 판매자 콘솔에서 제품마다 발급받습니다
57
+ client = LicenseClient(
58
+ Config(
59
+ base_url="https://api.developedby.dev",
60
+ client_id=client_id,
61
+ product_id="prod_01J9KZ3F7W2X8YQ4N6M5R1TBCD",
62
+ scopes=[Scope.ENTITLEMENT_READ, Scope.SESSION_WRITE, Scope.VERSION_READ],
63
+ device=platform.system_device_info(),
64
+ app=AppInfo(target="WINDOWS_X64", version="1.4.0"), # 콘솔에 업로드한 빌드의 버전과 같게
65
+ ports=Ports(
66
+ store=platform.default_credential_store("MyApp", client_id, logger),
67
+ fingerprint=platform.fingerprint_source(f"{platform.app_data_dir('MyApp')}/install-id"),
68
+ ),
69
+ )
70
+ )
71
+
72
+ if not client.has_credentials():
73
+ login = client.start_login()
74
+ show_code(login.user_code, login.verification_uri_complete) # 화면에 코드와 QR 코드를 보여 줍니다
75
+ login.wait() # 사용자가 브라우저에서 승인할 때까지 기다립니다. 취소는 login.cancel()로 합니다
76
+
77
+ session = client.session()
78
+
79
+
80
+ def on_state(state): # SDK의 스레드에서 불리므로, UI 작업은 UI 스레드로 넘기세요
81
+ match state:
82
+ # Degraded여도 offline_until까지는 계속 쓸 수 있습니다
83
+ case Active(claims=claims) | Degraded(claims=claims):
84
+ enable_features(claims) # exp와 sid는 기능 코드에서 쓰고, 참/거짓 하나로만 판단하지 마세요
85
+ case NeedsDecision():
86
+ ask_user(state) # DEVICE_IN_USE: "여기서 사용할까요?"에 동의하면 session.take_over()를 부릅니다
87
+ case Locked(code=code, correlation_id=cid):
88
+ lock_app(code, cid) # 오류 화면에 correlation_id를 보여 주세요
89
+
90
+
91
+ subscription = session.subscribe(on_state)
92
+ session.start()
93
+ # 앱을 끌 때
94
+ session.stop()
95
+ subscription.unsubscribe()
96
+ ```
97
+
98
+ ## 포트
99
+
100
+ 포트는 SDK가 HTTP 전송, 로그인 정보 저장, 시계 같은 바깥 기능을 쓰는 연결 지점입니다. 앱이 원하는 구현으로 교체할 수 있습니다.
101
+
102
+ 명세에서 쓰는 포트 이름은 표준 모듈 `random`, `logging`과 헷갈리지 않도록 다른 이름을 붙였습니다. Swift SDK, Kotlin SDK와 같은 이름입니다.
103
+
104
+ 포트는 모두
105
+ `typing.Protocol`이라서 메서드 모양만 맞추면 됩니다.
106
+
107
+ | 포트(명세 이름) | 기본 구현 | 직접 구현하거나 설정할 항목 |
108
+ |---|---|---|
109
+ | `HttpTransport`(Transport) | `UrllibTransport`입니다. 표준 `urllib`을 쓰고, 시간 초과는 30초이며, 리다이렉트를 따라가지 않습니다. | 프록시나 인증서 고정이 필요하면 직접 구현해 주세요. 이때 리다이렉트를 따라가지 않게 하는 것은 앱이 맡습니다. |
110
+ | `CredentialStore` | **메모리**에만 둡니다. 앱을 끄면 로그인이 사라집니다. | `platform.default_credential_store`, `keyring_credential_store`, `dpapi_credential_store`, `secret_tool_credential_store`, `file_credential_store` |
111
+ | `FingerprintSource` | 없습니다. 실행할 때마다 새 기기로 보일 수 있으며, 이때 경고 로그를 남깁니다. | `platform.fingerprint_source(설치 ID 파일)`를 사용해 주세요. 운영체제에 따라 MachineGuid, IOPlatformUUID, machine-id를 쓰고, 읽지 못하면 설치 ID를 씁니다. |
112
+ | `WallClock`, `TaskScheduler`, `RandomSource`(Clock, Scheduler, Random) | 시스템 시계, `ThreadScheduler`(데몬 타이머 스레드), `secrets` | 시험할 때 교체합니다. SDK는 시간이나 다른 작업을 기다릴 때 `sleep`과 `wait`만 씁니다. |
113
+ | `LogSink`(Logger) | 아무것도 기록하지 않습니다(`SilentLog`). | 로그에는 토큰이나 기기 지문 원본이 넘어오지 않습니다. |
114
+
115
+ `default_credential_store`는 운영체제마다 저장하는 곳이 다릅니다.
116
+
117
+ - Windows: DPAPI로 보호한 파일에 저장합니다.
118
+ - Linux: Secret Service에 저장합니다. `secret-tool`이 없으면 권한 0600 파일에 저장하고 경고를 남깁니다.
119
+ - macOS: 권한 0600 파일에 저장하고 경고를 남깁니다.
120
+
121
+ macOS에서 기본으로 키체인을 쓰지 않는 이유는 `security` 명령이 비밀 값을 명령 인자로 받기 때문입니다. TS, Go, Kotlin SDK와 같은 이유입니다.
122
+
123
+ **macOS 키체인**을 쓰려면 `pip install "bydev[keyring]"`로 설치한 뒤 `platform.keyring_credential_store(client_id)`를 사용해 주세요. 이때 `keyring` 패키지가
124
+ 키체인, Windows 자격 증명 관리자, Secret Service 가운데 알맞은 것을 선택합니다.
125
+
126
+ SDK는 비밀 값(refresh_token)을 명령줄 인자로 넘기지 않고,
127
+ `secret-tool`과 PowerShell에 표준 입력으로만 전달합니다.
128
+
129
+ **Linux 배포 패키지에는 `secret-tool`을 의존성으로 걸어 주세요.** 기본 저장소는 이 명령으로 Secret Service에 접근하는데, Debian과 Ubuntu 데스크톱의
130
+ 기본 설치에는 이 명령이 없습니다.
131
+
132
+ Ubuntu 26.04.1에서 확인했으며, Secret Service 자체는 돌고 있었습니다. .deb 패키지는 `libsecret-tools`를 `Depends`나
133
+ `Recommends`에 넣고, RPM(Fedora 등)과 Arch 패키지는 `libsecret`을 넣어 주세요.
134
+
135
+ 의존성을 지정할 수 없는 AppImage나 tar.gz 배포본에는 `secret-tool` 설치 방법을 안내해 주세요. 명령이 없으면 SDK는 권한 0600 파일에 저장하고 경고 로그를 남깁니다. `keyring_credential_store`는 D-Bus로 Secret Service에 바로 접근하므로 이
136
+ 명령이 필요 없습니다.
137
+
138
+ 이 점도 같은 Ubuntu에서 함께 확인했습니다.
139
+
140
+ ## 판매자 서버
141
+
142
+ ```python
143
+ from bydev import ServerVerifier, verify_webhook
144
+
145
+ # 웹훅: 받은 본문(bytes) 그대로 검증하세요. 파싱했다가 다시 만든 바이트로는 서명이 맞지 않습니다. 시크릿을 교체하는 중이면 둘 다 넘기세요
146
+ webhook = verify_webhook([secret], request.headers, request.body)
147
+
148
+ # 앱이 보낸 access_token과 licenseToken을 검증합니다. JWKS를 받아 캐시하므로 인스턴스 하나를 오래 쓰세요
149
+ verifier = ServerVerifier("https://api.developedby.dev", client_id)
150
+ claims = verifier.verify_access_token(token)
151
+ ```
152
+
153
+ ## 사용 조건
154
+
155
+ - **업데이트**: `check_for_update(target, current_version)`가 반환한 `update_status`가 `REQUIRED`이면, 업데이트하기 전까지 앱 실행을 막아 주세요.
156
+ `install.mode`가 `HOSTED`일 때는 다운로드한 파일을 설치하기 전에 `verify_download(data, check.install.sha256)`로 확인해 주세요.
157
+ 업데이트 제공 기한이 있는 구매자는 결과에 `entitled`가 들어 있습니다. 그때는 최상위 대신 `entitled.release`를 따라 주세요.
158
+ 최상위 최신 버전은 그 구매자가 실행할 수 없는 버전일 수 있고, `entitled.release`가 비어 있으면 그 대상에 제공 범위 안의 버전이 없습니다.
159
+ - **오류**: 실패하면 `BydevError`가 발생합니다. 분기는 `code`로 하고, 비교할 값은 생성된 `Codes`에 있습니다. `message`는 화면에 보여 주는 용도로만
160
+ 사용해 주세요. `is_transient`가 참이면 다시 시도해 볼 만한 오류입니다.
161
+ - **모르는 값**: `EntitlementStatus` 같은 열거 값은 `str`입니다. 그래서 이 버전의 SDK가 모르는 새 값이 와도 그대로 담깁니다. `match`에는 `case _`를
162
+ 두어 주세요.
163
+
164
+ 모델은 frozen dataclass이고 속성 이름은 snake_case입니다. 모든 모델에는 `to_dict()`가 있어서 기록하거나 진단할 때 쓸 수 있으며, 이때 키는
165
+ API와 같은 camelCase입니다.
166
+ - 패키지에 타입 힌트(`py.typed`)가 들어 있으며, mypy `--strict`로 검사합니다.
167
+ - 라이선스는 MIT 또는 Apache-2.0입니다.
168
+
169
+ ## 출처 확인
170
+
171
+ 이 꾸러미는 공개 저장소 `developedby-dev/sdk-python`의 GitHub Actions가 판 태그에서 짓고 올립니다. PyPI에 올린 파일에는 출처 증명(PEP 740)이 있습니다. PyPI 파일 화면의 「Provenance」에서 지은 저장소와 워크플로를 볼 수 있습니다.
172
+
173
+ ## 개발
174
+
175
+ 개발 명령은 [uv](https://docs.astral.sh/uv/)로 실행합니다.
176
+
177
+ | 명령 | 하는 일 |
178
+ |---|---|
179
+ | `uv run --frozen pytest -q` | 시험을 돌립니다. 실제 전송 시험은 적합성 시험용 가짜 서버를 HTTP 모드로 node에서 띄워 확인하며, 쓸 node는 `BYDEV_NODE`로 바꿀 수 있습니다. |
180
+ | `uv run --frozen ruff format .` | 서식을 맞춥니다. |
181
+ | `uv run --frozen ruff check .` · `uv run --frozen mypy` | 린트와 타입 검사(strict)를 합니다. |
182
+ | `uv run --frozen python harness/harness.py` | 적합성 하네스를 실행합니다. |
183
+ | `pnpm sdk:check python` | 린트, 서식, 타입 검사, 시험, 적합성 시나리오 48개를 모두 돌립니다. |
184
+
185
+ `src/bydev/_generated.py`는 생성된 파일이며, `pnpm --filter @bydev/sdk-codegen generate`로 다시 만듭니다. 이 파일은 ruff 검사에서 뺍니다.
bydev-0.1.0/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # 데브 SDK: Python
2
+
3
+ 데브 라이선스 API의 공식 Python SDK입니다. PySide, Tkinter, wxPython으로 만든 데스크톱 앱과 판매자 서버에서 씁니다.
4
+
5
+ 의존성은 Ed25519 처리에 쓰는
6
+ `cryptography` 하나뿐입니다. HTTP는 표준 `urllib`, JSON은 표준 `json`으로 처리합니다.
7
+
8
+ 모든 언어의 SDK가 함께 따르는 [공통 동작 명세](https://github.com/developedby-dev/sdk-spec/blob/main/spec/README.md)대로
9
+ 동작하고, [적합성 시험 시나리오](https://github.com/developedby-dev/sdk-spec/tree/main/conformance/scenarios)를 모두 통과합니다.
10
+
11
+ | 지원 | 버전 |
12
+ |---|---|
13
+ | 동작 명세 | 1.2.0 |
14
+ | API | v1 |
15
+ | Python | 3.11 이상 |
16
+ | 운영체제 | Windows, macOS, Linux |
17
+
18
+ 패키지 이름은 `bydev`입니다. 지금 PyPI에 있는 0.x 판은 이름을 먼저 등록하려고 낸 미리보기입니다. 1.0.0은 서비스 오픈과 함께 내며, 그 전에는
19
+ 호환되지 않는 변경이 있을 수 있습니다. 판매하는 앱에는 1.0.0 이상을 써 주세요.
20
+
21
+ ## 빠른 시작
22
+
23
+ 이 SDK는 **블로킹 API**입니다. UI 스레드에서 부르지 말고 작업 스레드에서 호출해 주세요.
24
+
25
+ asyncio 앱에서는 `bydev.aio.AsyncLicenseClient`를 쓰면 됩니다.
26
+ 같은 클라이언트를 `asyncio.to_thread`로 감싼 것입니다.
27
+
28
+ ```python
29
+ from bydev import Active, AppInfo, Config, Degraded, LicenseClient, Locked, NeedsDecision, Ports, Scope
30
+ from bydev import platform
31
+
32
+ client_id = "cli_01J9M0Y6X4N3Q8ZD5R2KT7VCPW" # 판매자 콘솔에서 제품마다 발급받습니다
33
+ client = LicenseClient(
34
+ Config(
35
+ base_url="https://api.developedby.dev",
36
+ client_id=client_id,
37
+ product_id="prod_01J9KZ3F7W2X8YQ4N6M5R1TBCD",
38
+ scopes=[Scope.ENTITLEMENT_READ, Scope.SESSION_WRITE, Scope.VERSION_READ],
39
+ device=platform.system_device_info(),
40
+ app=AppInfo(target="WINDOWS_X64", version="1.4.0"), # 콘솔에 업로드한 빌드의 버전과 같게
41
+ ports=Ports(
42
+ store=platform.default_credential_store("MyApp", client_id, logger),
43
+ fingerprint=platform.fingerprint_source(f"{platform.app_data_dir('MyApp')}/install-id"),
44
+ ),
45
+ )
46
+ )
47
+
48
+ if not client.has_credentials():
49
+ login = client.start_login()
50
+ show_code(login.user_code, login.verification_uri_complete) # 화면에 코드와 QR 코드를 보여 줍니다
51
+ login.wait() # 사용자가 브라우저에서 승인할 때까지 기다립니다. 취소는 login.cancel()로 합니다
52
+
53
+ session = client.session()
54
+
55
+
56
+ def on_state(state): # SDK의 스레드에서 불리므로, UI 작업은 UI 스레드로 넘기세요
57
+ match state:
58
+ # Degraded여도 offline_until까지는 계속 쓸 수 있습니다
59
+ case Active(claims=claims) | Degraded(claims=claims):
60
+ enable_features(claims) # exp와 sid는 기능 코드에서 쓰고, 참/거짓 하나로만 판단하지 마세요
61
+ case NeedsDecision():
62
+ ask_user(state) # DEVICE_IN_USE: "여기서 사용할까요?"에 동의하면 session.take_over()를 부릅니다
63
+ case Locked(code=code, correlation_id=cid):
64
+ lock_app(code, cid) # 오류 화면에 correlation_id를 보여 주세요
65
+
66
+
67
+ subscription = session.subscribe(on_state)
68
+ session.start()
69
+ # 앱을 끌 때
70
+ session.stop()
71
+ subscription.unsubscribe()
72
+ ```
73
+
74
+ ## 포트
75
+
76
+ 포트는 SDK가 HTTP 전송, 로그인 정보 저장, 시계 같은 바깥 기능을 쓰는 연결 지점입니다. 앱이 원하는 구현으로 교체할 수 있습니다.
77
+
78
+ 명세에서 쓰는 포트 이름은 표준 모듈 `random`, `logging`과 헷갈리지 않도록 다른 이름을 붙였습니다. Swift SDK, Kotlin SDK와 같은 이름입니다.
79
+
80
+ 포트는 모두
81
+ `typing.Protocol`이라서 메서드 모양만 맞추면 됩니다.
82
+
83
+ | 포트(명세 이름) | 기본 구현 | 직접 구현하거나 설정할 항목 |
84
+ |---|---|---|
85
+ | `HttpTransport`(Transport) | `UrllibTransport`입니다. 표준 `urllib`을 쓰고, 시간 초과는 30초이며, 리다이렉트를 따라가지 않습니다. | 프록시나 인증서 고정이 필요하면 직접 구현해 주세요. 이때 리다이렉트를 따라가지 않게 하는 것은 앱이 맡습니다. |
86
+ | `CredentialStore` | **메모리**에만 둡니다. 앱을 끄면 로그인이 사라집니다. | `platform.default_credential_store`, `keyring_credential_store`, `dpapi_credential_store`, `secret_tool_credential_store`, `file_credential_store` |
87
+ | `FingerprintSource` | 없습니다. 실행할 때마다 새 기기로 보일 수 있으며, 이때 경고 로그를 남깁니다. | `platform.fingerprint_source(설치 ID 파일)`를 사용해 주세요. 운영체제에 따라 MachineGuid, IOPlatformUUID, machine-id를 쓰고, 읽지 못하면 설치 ID를 씁니다. |
88
+ | `WallClock`, `TaskScheduler`, `RandomSource`(Clock, Scheduler, Random) | 시스템 시계, `ThreadScheduler`(데몬 타이머 스레드), `secrets` | 시험할 때 교체합니다. SDK는 시간이나 다른 작업을 기다릴 때 `sleep`과 `wait`만 씁니다. |
89
+ | `LogSink`(Logger) | 아무것도 기록하지 않습니다(`SilentLog`). | 로그에는 토큰이나 기기 지문 원본이 넘어오지 않습니다. |
90
+
91
+ `default_credential_store`는 운영체제마다 저장하는 곳이 다릅니다.
92
+
93
+ - Windows: DPAPI로 보호한 파일에 저장합니다.
94
+ - Linux: Secret Service에 저장합니다. `secret-tool`이 없으면 권한 0600 파일에 저장하고 경고를 남깁니다.
95
+ - macOS: 권한 0600 파일에 저장하고 경고를 남깁니다.
96
+
97
+ macOS에서 기본으로 키체인을 쓰지 않는 이유는 `security` 명령이 비밀 값을 명령 인자로 받기 때문입니다. TS, Go, Kotlin SDK와 같은 이유입니다.
98
+
99
+ **macOS 키체인**을 쓰려면 `pip install "bydev[keyring]"`로 설치한 뒤 `platform.keyring_credential_store(client_id)`를 사용해 주세요. 이때 `keyring` 패키지가
100
+ 키체인, Windows 자격 증명 관리자, Secret Service 가운데 알맞은 것을 선택합니다.
101
+
102
+ SDK는 비밀 값(refresh_token)을 명령줄 인자로 넘기지 않고,
103
+ `secret-tool`과 PowerShell에 표준 입력으로만 전달합니다.
104
+
105
+ **Linux 배포 패키지에는 `secret-tool`을 의존성으로 걸어 주세요.** 기본 저장소는 이 명령으로 Secret Service에 접근하는데, Debian과 Ubuntu 데스크톱의
106
+ 기본 설치에는 이 명령이 없습니다.
107
+
108
+ Ubuntu 26.04.1에서 확인했으며, Secret Service 자체는 돌고 있었습니다. .deb 패키지는 `libsecret-tools`를 `Depends`나
109
+ `Recommends`에 넣고, RPM(Fedora 등)과 Arch 패키지는 `libsecret`을 넣어 주세요.
110
+
111
+ 의존성을 지정할 수 없는 AppImage나 tar.gz 배포본에는 `secret-tool` 설치 방법을 안내해 주세요. 명령이 없으면 SDK는 권한 0600 파일에 저장하고 경고 로그를 남깁니다. `keyring_credential_store`는 D-Bus로 Secret Service에 바로 접근하므로 이
112
+ 명령이 필요 없습니다.
113
+
114
+ 이 점도 같은 Ubuntu에서 함께 확인했습니다.
115
+
116
+ ## 판매자 서버
117
+
118
+ ```python
119
+ from bydev import ServerVerifier, verify_webhook
120
+
121
+ # 웹훅: 받은 본문(bytes) 그대로 검증하세요. 파싱했다가 다시 만든 바이트로는 서명이 맞지 않습니다. 시크릿을 교체하는 중이면 둘 다 넘기세요
122
+ webhook = verify_webhook([secret], request.headers, request.body)
123
+
124
+ # 앱이 보낸 access_token과 licenseToken을 검증합니다. JWKS를 받아 캐시하므로 인스턴스 하나를 오래 쓰세요
125
+ verifier = ServerVerifier("https://api.developedby.dev", client_id)
126
+ claims = verifier.verify_access_token(token)
127
+ ```
128
+
129
+ ## 사용 조건
130
+
131
+ - **업데이트**: `check_for_update(target, current_version)`가 반환한 `update_status`가 `REQUIRED`이면, 업데이트하기 전까지 앱 실행을 막아 주세요.
132
+ `install.mode`가 `HOSTED`일 때는 다운로드한 파일을 설치하기 전에 `verify_download(data, check.install.sha256)`로 확인해 주세요.
133
+ 업데이트 제공 기한이 있는 구매자는 결과에 `entitled`가 들어 있습니다. 그때는 최상위 대신 `entitled.release`를 따라 주세요.
134
+ 최상위 최신 버전은 그 구매자가 실행할 수 없는 버전일 수 있고, `entitled.release`가 비어 있으면 그 대상에 제공 범위 안의 버전이 없습니다.
135
+ - **오류**: 실패하면 `BydevError`가 발생합니다. 분기는 `code`로 하고, 비교할 값은 생성된 `Codes`에 있습니다. `message`는 화면에 보여 주는 용도로만
136
+ 사용해 주세요. `is_transient`가 참이면 다시 시도해 볼 만한 오류입니다.
137
+ - **모르는 값**: `EntitlementStatus` 같은 열거 값은 `str`입니다. 그래서 이 버전의 SDK가 모르는 새 값이 와도 그대로 담깁니다. `match`에는 `case _`를
138
+ 두어 주세요.
139
+
140
+ 모델은 frozen dataclass이고 속성 이름은 snake_case입니다. 모든 모델에는 `to_dict()`가 있어서 기록하거나 진단할 때 쓸 수 있으며, 이때 키는
141
+ API와 같은 camelCase입니다.
142
+ - 패키지에 타입 힌트(`py.typed`)가 들어 있으며, mypy `--strict`로 검사합니다.
143
+ - 라이선스는 MIT 또는 Apache-2.0입니다.
144
+
145
+ ## 출처 확인
146
+
147
+ 이 꾸러미는 공개 저장소 `developedby-dev/sdk-python`의 GitHub Actions가 판 태그에서 짓고 올립니다. PyPI에 올린 파일에는 출처 증명(PEP 740)이 있습니다. PyPI 파일 화면의 「Provenance」에서 지은 저장소와 워크플로를 볼 수 있습니다.
148
+
149
+ ## 개발
150
+
151
+ 개발 명령은 [uv](https://docs.astral.sh/uv/)로 실행합니다.
152
+
153
+ | 명령 | 하는 일 |
154
+ |---|---|
155
+ | `uv run --frozen pytest -q` | 시험을 돌립니다. 실제 전송 시험은 적합성 시험용 가짜 서버를 HTTP 모드로 node에서 띄워 확인하며, 쓸 node는 `BYDEV_NODE`로 바꿀 수 있습니다. |
156
+ | `uv run --frozen ruff format .` | 서식을 맞춥니다. |
157
+ | `uv run --frozen ruff check .` · `uv run --frozen mypy` | 린트와 타입 검사(strict)를 합니다. |
158
+ | `uv run --frozen python harness/harness.py` | 적합성 하네스를 실행합니다. |
159
+ | `pnpm sdk:check python` | 린트, 서식, 타입 검사, 시험, 적합성 시나리오 48개를 모두 돌립니다. |
160
+
161
+ `src/bydev/_generated.py`는 생성된 파일이며, `pnpm --filter @bydev/sdk-codegen generate`로 다시 만듭니다. 이 파일은 ruff 검사에서 뺍니다.