Skip to content

Commit 17715c0

Browse files
authored
Merge pull request #15 from iconloop/develop
2 parents 87e6e35 + d93d748 commit 17715c0

File tree

93 files changed

+9012
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+9012
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: publish to test pypi
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
release:
7+
types: [published]
8+
workflow_dispatch:
9+
inputs:
10+
test_deploy:
11+
description: 'test deploy to https://test.pypi.org'
12+
required: false
13+
default: 'false'
14+
15+
jobs:
16+
unittest:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
python-version: ["3.8", "3.9", "3.10", "3.11"]
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
cache: pip
28+
- name: Install dependency
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -e .[dev]
32+
- name: Run Test
33+
run: |
34+
python -m pytest -ra
35+
36+
deploy:
37+
needs: unittest
38+
if: github.event.inputs.test_deploy == 'true'
39+
runs-on: ubuntu-latest
40+
environment: testpypi
41+
permissions:
42+
id-token: write
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: "3.8"
49+
cache: pip
50+
- name: Install dependency
51+
run: |
52+
python -m pip install --upgrade pip build
53+
echo "::notice:: pip list"
54+
pip list
55+
- name: Build package
56+
id: build_package
57+
run: |
58+
python -m build
59+
echo "::notice:: ls -al dist"
60+
ls -al dist
61+
- name: Publish package
62+
uses: pypa/gh-action-pypi-publish@release/v1
63+
with:
64+
verbose: true
65+
repository-url: https://test.pypi.org/legacy/

.github/workflows/didsdk-deploy.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: unittest and publish to pypi
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
unittest:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.8", "3.9", "3.10", "3.11"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
cache: pip
22+
- name: Install dependency
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -e .[dev]
26+
- name: Run Test
27+
run: |
28+
python -m pytest -ra
29+
30+
deploy:
31+
needs: unittest
32+
if: github.event_name == 'release'
33+
runs-on: ubuntu-latest
34+
environment: release
35+
permissions:
36+
id-token: write
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Set up Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.8"
43+
cache: pip
44+
- name: Install dependency
45+
run: |
46+
python -m pip install --upgrade pip build
47+
echo "::notice:: pip list"
48+
pip list
49+
- name: Build package
50+
id: build_package
51+
run: |
52+
python -m build
53+
echo "::notice:: ls -al dist"
54+
ls -al dist
55+
- name: Publish package
56+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/linting.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-python@v5
11+
with:
12+
python-version: '3.11'
13+
cache: pip
14+
- name: check sort imports with isort
15+
uses: isort/isort-action@v1
16+
with:
17+
configuration: "--check-only --diff --verbose"
18+
sortPaths: "./didsdk ./tests"
19+
20+
- name: check code formatting with black
21+
uses: psf/black@stable
22+
with:
23+
options: "--check --verbose"
24+
src: "./didsdk ./tests"
25+
version: "~= 23.0"

.gitignore

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
### Example user template template
2+
### Example user template
3+
4+
# IntelliJ project files
5+
.idea
6+
*.iml
7+
out
8+
gen
9+
### Python template
10+
# Byte-compiled / optimized / DLL files
11+
__pycache__/
12+
*.py[cod]
13+
*$py.class
14+
15+
# C extensions
16+
*.so
17+
18+
# Distribution / packaging
19+
.Python
20+
build/
21+
develop-eggs/
22+
dist/
23+
downloads/
24+
eggs/
25+
.eggs/
26+
lib/
27+
lib64/
28+
parts/
29+
sdist/
30+
var/
31+
wheels/
32+
share/python-wheels/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
MANIFEST
37+
38+
# PyInstaller
39+
# Usually these files are written by a python script from a template
40+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
41+
*.manifest
42+
*.spec
43+
44+
# Installer logs
45+
pip-log.txt
46+
pip-delete-this-directory.txt
47+
48+
# Unit test / coverage reports
49+
htmlcov/
50+
.tox/
51+
.nox/
52+
.coverage
53+
.coverage.*
54+
.cache
55+
nosetests.xml
56+
coverage.xml
57+
*.cover
58+
*.py,cover
59+
.hypothesis/
60+
.pytest_cache/
61+
cover/
62+
63+
# Translations
64+
*.mo
65+
*.pot
66+
67+
# Django stuff:
68+
*.log
69+
local_settings.py
70+
db.sqlite3
71+
db.sqlite3-journal
72+
73+
# Flask stuff:
74+
instance/
75+
.webassets-cache
76+
77+
# Scrapy stuff:
78+
.scrapy
79+
80+
# Sphinx documentation
81+
docs/_build/
82+
83+
# PyBuilder
84+
.pybuilder/
85+
target/
86+
87+
# Jupyter Notebook
88+
.ipynb_checkpoints
89+
90+
# IPython
91+
profile_default/
92+
ipython_config.py
93+
94+
# pyenv
95+
# For a library or package, you might want to ignore these files since the code is
96+
# intended to run in multiple environments; otherwise, check them in:
97+
# .python-version
98+
99+
# pipenv
100+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
101+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
102+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
103+
# install all needed dependencies.
104+
#Pipfile.lock
105+
106+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
107+
__pypackages__/
108+
109+
# Celery stuff
110+
celerybeat-schedule
111+
celerybeat.pid
112+
113+
# SageMath parsed files
114+
*.sage.py
115+
116+
# Environments
117+
.env
118+
.venv
119+
env/
120+
venv/
121+
ENV/
122+
env.bak/
123+
venv.bak/
124+
125+
# Spyder project settings
126+
.spyderproject
127+
.spyproject
128+
129+
# Rope project settings
130+
.ropeproject
131+
132+
# mkdocs documentation
133+
/site
134+
135+
# mypy
136+
.mypy_cache/
137+
.dmypy.json
138+
dmypy.json
139+
140+
# Pyre type checker
141+
.pyre/
142+
143+
# pytype static type analyzer
144+
.pytype/
145+
146+
# Cython debug symbols
147+
cython_debug/
148+

.pre-commit-config.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: https://github.com/pycqa/isort
3+
rev: 5.12.0
4+
hooks:
5+
- id: isort
6+
7+
- repo: https://github.com/psf/black-pre-commit-mirror
8+
rev: 23.12.1
9+
hooks:
10+
- id: black
11+
# https://pre-commit.com/#top_level-default_language_version
12+
language_version: python3.11
13+
args: [--line-length=120]

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22

33
This SDK is used not only to create and manage `ICON DID`, but also to issue and verify `credentials` and `presentations`.
44

5+
### Configure
6+
Add some configurations of `didsdk` to a `.env` file in your project.
7+
~~~
8+
TX_RETRY_COUNT=int[default:5]
9+
TX_SLEEP_TIME=int[default:1]
10+
DIDSDK_LOG_ENABLE_LOGGER=bool[default:false]
11+
~~~

VERSION

-1
This file was deleted.

didsdk/__about__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.0"

didsdk/__init__.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from cryptography.hazmat.primitives.asymmetric.ec import SECP256K1
2+
from joserfc.jws import JWSRegistry
3+
from joserfc.rfc7518.ec_key import CURVES_DSS, DSS_CURVES
4+
from joserfc.rfc7518.jws_algs import ECAlgModel
5+
from loguru import logger
6+
7+
from didsdk.config import settings
8+
9+
if settings.DIDSDK_LOG_ENABLE_LOGGER:
10+
logger.enable(__name__)
11+
else:
12+
logger.disable(__name__)
13+
14+
logger.debug(f"{settings.DIDSDK_LOG_ENABLE_LOGGER=}")
15+
logger.debug(f"{settings.__repr_name__()}: {settings.dict()}")
16+
17+
18+
def register_p_256k():
19+
JWSRegistry.register(ECAlgModel("ES256K", "P-256K", 256))
20+
DSS_CURVES["P-256K"] = SECP256K1
21+
CURVES_DSS["P-256K"] = "secp256k1"
22+
23+
24+
register_p_256k()

didsdk/config.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Union
2+
3+
from pydantic import BaseSettings
4+
5+
6+
class DidSettings(BaseSettings):
7+
DIDSDK_PROJECT_NAME: str = "did-sdk-python"
8+
DIDSDK_TX_RETRY_COUNT: int = 5
9+
# Second
10+
DIDSDK_TX_SLEEP_TIME: Union[int, float] = 1
11+
DIDSDK_LOG_ENABLE_LOGGER: bool = False
12+
13+
class Config:
14+
case_sensitive = True
15+
16+
17+
settings = DidSettings()

0 commit comments

Comments
 (0)