Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added commandline interface to library #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jwilliams99
Copy link

Added a simple CLI so other scripts can use bitid without having to implement natively.

@LaurentMT
Copy link
Owner

HI jwilliams99,

ACK to the idea. Just 2 remarks:

  • Can we rename the script in bitid_cli.py ?
  • The syntax used for print function isn't valid in python 3.3.3 (parentheses are mandatory).

@jwilliams99
Copy link
Author

Thanks for the feedback. This is my first python script, and I'll get the
changes done today!
On 9 Apr 2016 12:15, "LaurentMT" notifications@github.com wrote:

HI jwilliams99,

ACK to the idea. Just 2 remarks:

  • Can we rename the script in bitid_cli.py ?
  • The syntax used for print function isn't valid in python 3.3
    (parentheses are mandatory).


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#5 (comment)

@jwilliams99
Copy link
Author

comments addressed, file uploaded.

@LaurentMT
Copy link
Owner

I've done a few tests on python 3.3.3. It works fine.

A few minor remarks:

  • comment should mention bitid_cli (mea culpa ;)
  • there seems to be a mismatch between the help indicating "-c - n" params to generate an auth request and code which expects an empty nonce. Imho, we should be able to generate an auth request with or without the "-n" parameter.
  • Auth request is regenerated when we verify an auth request (call with -a -u -s -c" params). Is there a need for this ?

For the last 2 points, I think we may use :

if message['address'] != '':
    message['valid_address'] = str( bitid.address_valid( message['address'] ) )

if message['callback'] != '':
    if message['uri'] != '':
        message['valid_uri'] = str( bitid.uri_valid( message['uri'], message['callback'] ) )

        if message['address'] != '' and message['signature'] != '':
            valid_signature = bitid.signature_valid( message['address'], message['signature'], message['uri'], message['callback'] )
            message['valid_signature'] = str( valid_signature )
    else:
        if message['nonce'] == '':
            message['nonce'] = bitid.generate_nonce()
        message['uri'] = bitid.build_uri( message['callback'], message['nonce'] )
        message['qrcode'] = bitid.qrcode( message['uri'] )

What do you think about it?

At last, feel free to modify the README.md in order to add a chapter about this tool (before the "Integration example" chapter ?) and to add your name in the list of authors. Thanks for your contribution !

@jwilliams99
Copy link
Author

Point #2, you're correct, i've forgotten to update the help once i got the
code to do what i wanted.

Your suggestion for points 2 & 3 are better than mine ;)

I'm pretty happy to roll with your suggestions. My pleasure for the
contrib. I'll update the README and add my name to the list, appreciated
:) your lib kicks arse, thank you!

On 10 April 2016 at 06:29, LaurentMT notifications@github.com wrote:

I've done a few tests on python 3.3.3. It works fine.

A few minor remarks:

  • comment should mention bitid_cli (mea culpa ;)
  • there seems to be a mismatch between the help indicating "-c - n"
    params to generate an auth request and code which expects an empty nonce.
    Imho, we should be able to generate an auth request with or without the
    "-n" parameter.
  • Auth request is regenerated when we verify an auth request (call
    with -a -u -s -c" params). Is there a need for this ?

For the last 2 points, I think we may use :

if message['address'] != '':
message['valid_address'] = str( bitid.address_valid( message['address'] ) )

if message['callback'] != '':
if message['uri'] != '':
message['valid_uri'] = str( bitid.uri_valid( message['uri'], message['callback'] ) )

    if message['address'] != '' and message['signature'] != '':
        valid_signature = bitid.signature_valid( message['address'], message['signature'], message['uri'], message['callback'] )
        message['valid_signature'] = str( valid_signature )
else:
    if message['nonce'] == '':
        message['nonce'] = bitid.generate_nonce()
    message['uri'] = bitid.build_uri( message['callback'], message['nonce'] )
    message['qrcode'] = bitid.qrcode( message['uri'] )

What do you think about it?

At last, feel free to modify the README.md in order to add a chapter about
this tool (before the "Integration example" chapter ?) and to add your name
in the list of authors. Thanks for your contribution !


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#5 (comment)

@jwilliams99
Copy link
Author

There seems to be a bug in the cli whereby if the nonce is passed in, the
condition:

if message['nonce'] == '':

                message['nonce'] = bitid.generate_nonce()

doesnt seem to recognise it. my python isn't good enough to understand
whats going on as message['nonce'] seems populated (ref some debug print
statement in my current commit)

if you'd take a look at it, i'm sure you'd see the problem straight away ;)

On 11 April 2016 at 22:14, Ryszard ryszard99@gmail.com wrote:

Point #2, you're correct, i've forgotten to update the help once i got the
code to do what i wanted.

Your suggestion for points 2 & 3 are better than mine ;)

I'm pretty happy to roll with your suggestions. My pleasure for the
contrib. I'll update the README and add my name to the list, appreciated
:) your lib kicks arse, thank you!

On 10 April 2016 at 06:29, LaurentMT notifications@github.com wrote:

I've done a few tests on python 3.3.3. It works fine.

A few minor remarks:

  • comment should mention bitid_cli (mea culpa ;)
  • there seems to be a mismatch between the help indicating "-c - n"
    params to generate an auth request and code which expects an empty nonce.
    Imho, we should be able to generate an auth request with or without the
    "-n" parameter.
  • Auth request is regenerated when we verify an auth request (call
    with -a -u -s -c" params). Is there a need for this ?

For the last 2 points, I think we may use :

if message['address'] != '':
message['valid_address'] = str( bitid.address_valid( message['address'] ) )

if message['callback'] != '':
if message['uri'] != '':
message['valid_uri'] = str( bitid.uri_valid( message['uri'], message['callback'] ) )

    if message['address'] != '' and message['signature'] != '':
        valid_signature = bitid.signature_valid( message['address'], message['signature'], message['uri'], message['callback'] )
        message['valid_signature'] = str( valid_signature )
else:
    if message['nonce'] == '':
        message['nonce'] = bitid.generate_nonce()
    message['uri'] = bitid.build_uri( message['callback'], message['nonce'] )
    message['qrcode'] = bitid.qrcode( message['uri'] )

What do you think about it?

At last, feel free to modify the README.md in order to add a chapter
about this tool (before the "Integration example" chapter ?) and to add
your name in the list of authors. Thanks for your contribution !


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#5 (comment)

@LaurentMT
Copy link
Owner

I think it's just a problem of indentation.
You should remove one level of indentation for lines 38 to 54 (and get the tests out of the for loop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants