Skip to content

Commit

Permalink
Some structure for the project, an initial command for launching an a…
Browse files Browse the repository at this point in the history
…gent and an Authenticater for signing responses and verifying signed requests.
  • Loading branch information
pfeairheller committed Feb 5, 2023
1 parent c0674b3 commit b534b88
Show file tree
Hide file tree
Showing 19 changed files with 1,125 additions and 0 deletions.
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# requirements.txt
# Best practices for setup.py vs requirements.txt
# https://caremad.io/posts/2013/07/setup-vs-requirement/
# https://pip.pypa.io/en/stable/reference/pip_install/#install-index-url

# enables pip install -r requirements.txt to work with setup.py dependencies
# pull the dependencies from setup.py for keri from pip index
--index-url https://pypi.org/simple/ # pypi base pip index or local pip index

--editable . # install as editable
92 changes: 92 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
$ python setup.py register sdist upload
First Time register project on pypi
https://pypi.org/manage/projects/
Pypi Release
$ pip3 install twine
$ python3 setup.py sdist
$ twine upload dist/keri-0.0.1.tar.gz
Create release git:
$ git tag -a v0.4.2 -m "bump version"
$ git push --tags
$ git checkout -b release_0.4.2
$ git push --set-upstream origin release_0.4.2
$ git checkout master
Best practices for setup.py and requirements.txt
https://caremad.io/posts/2013/07/setup-vs-requirement/
"""

from glob import glob
from os.path import basename
from os.path import splitext

from setuptools import find_packages, setup
setup(
name='signify',
version='0.0.1', # also change in src/signify/__init__.py
license='Apache Software License 2.0',
description='Signify',
long_description="KERI Signing at the Edge Infrastructure",
author='Philip S. Feairheller',
author_email='[email protected]',
url='https://github.com/WebOfTrust/signifypy',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
# uncomment if you test on these interpreters:
# 'Programming Language :: Python :: Implementation :: PyPy',
# 'Programming Language :: Python :: Implementation :: IronPython',
# 'Programming Language :: Python :: Implementation :: Jython',
# 'Programming Language :: Python :: Implementation :: Stackless',
'Topic :: Utilities',
],
project_urls={
'Documentation': 'https://signify.readthedocs.io/',
'Changelog': 'https://signify.readthedocs.io/en/latest/changelog.html',
'Issue Tracker': 'https://github.com/WebOfTrust/signify/issues',
},
keywords=[
# eg: 'keyword1', 'keyword2', 'keyword3',
],
python_requires='>=3.10.4',
install_requires=[
'keri>=0.6.9',
'multicommand>=1.0.0',
'falcon>=3.1.0',
'http_sfv>=0.9.8'
],
extras_require={
},
tests_require=[
'coverage>=6.5.0',
'pytest>=7.2.0',
'pytest-shell>=0.3.2'
],
setup_requires=[
],
entry_points={
'console_scripts': [
]
},
)

Empty file added src/__init__.py
Empty file.
Empty file added src/signify/__init__.py
Empty file.
Empty file added src/signify/app/__init__.py
Empty file.
Empty file added src/signify/app/cli/__init__.py
Empty file.
Empty file.
92 changes: 92 additions & 0 deletions src/signify/app/cli/commands/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# -*- encoding: utf-8 -*-
"""
KERI
keri.kli.witness module
Witness command line interface
"""
import argparse
import logging

from keri import __version__
from keri import help
from keri.app import directing, indirecting, habbing, keeping
from keri.app.cli.common import existing

from src.signify.app import signifying

d = "Runs KERI Signify Agent\n"
d += "\tExample:\nkli agent\n"
parser = argparse.ArgumentParser(description=d)
parser.set_defaults(handler=lambda args: launch(args))
parser.add_argument('-V', '--version',
action='version',
version=__version__,
help="Prints out version of script runner.")
parser.add_argument('-a', '--admin-http-port',
action='store',
default=5623,
help="Admin port number the HTTP server listens on. Default is 5623.")
parser.add_argument('-H', '--http',
action='store',
default=5631,
help="Local port number the HTTP server listens on. Default is 5631.")
parser.add_argument('-T', '--tcp',
action='store',
default=5632,
help="Local port number the HTTP server listens on. Default is 5632.")
parser.add_argument('-c', '--controller', required=True,
help="Identifier prefix to accept control messages from.")
parser.add_argument('-n', '--name',
action='store',
default="agent",
help="Name of controller. Default is witness.")
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--alias', '-a', help='human readable alias for the new identifier prefix', required=True)
parser.add_argument('--passcode', '-p', help='22 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument('--config-file',
dest="configFile",
action='store',
default="",
help="configuration filename")
parser.add_argument("--config-dir",
dest="configDir",
action="store",
default=None,
help="directory override for configuration data")


def launch(args):
help.ogler.level = logging.CRITICAL
help.ogler.reopen(name=args.name, temp=True, clear=True)

logger = help.ogler.getLogger()

logger.info("\n******* Starting Agent for %s listening: http/%s, tcp/%s "
".******\n\n", args.name, args.http, args.tcp)

runAgent(name=args.name,
base=args.base,
alias=args.alias,
bran=args.bran,
tcp=int(args.tcp),
http=int(args.http))

logger.info("\n******* Ended Agent for %s listening: http/%s, tcp/%s"
".******\n\n", args.name, args.http, args.tcp)


def runAgent(name="witness", base="", alias="witness", bran="", tcp=5631, http=5632, expire=0.0):
"""
Setup and run one witness
"""

oers = []
doers.extend(signifying.setup(alias=alias,
hby=hby,
tcpPort=tcp,
httpPort=http))

directing.runController(doers=doers, expire=expire)
34 changes: 34 additions & 0 deletions src/signify/app/cli/signify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
"""
keri.kli.commands module
"""
import multicommand
from keri import help

from keri.app import directing
from keri.app.cli import commands

logger = help.ogler.getLogger()


def main():
parser = multicommand.create_parser(commands)
args = parser.parse_args()

if not hasattr(args, 'handler'):
parser.print_help()
return

try:
doers = args.handler(args)
directing.runController(doers=doers, expire=0.0)

except Exception as ex:
print(f"ERR: {ex}")
return -1
# raise ex


if __name__ == "__main__":
main()
16 changes: 16 additions & 0 deletions src/signify/app/keeping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- encoding: utf-8 -*-
"""
KERI
signify.app.keeping module
"""


def loadEnds(app):
pass


class KeeperEnd:

def __init__(self, ks):
self.ks = ks
Loading

0 comments on commit b534b88

Please sign in to comment.