Skip to content

Commit

Permalink
type hint the create and get methods
Browse files Browse the repository at this point in the history
  • Loading branch information
YSaxon authored and bodik committed Jun 8, 2023
1 parent ade75de commit 204628c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions soft_webauthn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import os
from base64 import urlsafe_b64encode
from struct import pack
from typing import Dict, Union

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from fido2 import cbor
from fido2.cose import ES256
from fido2.webauthn import AttestedCredentialData
from fido2.utils import sha256
from fido2.webauthn import (AttestedCredentialData, CredentialCreationOptions, CredentialRequestOptions)


class SoftWebauthnDevice():
Expand Down Expand Up @@ -48,7 +49,7 @@ def cred_as_attested(self):
self.credential_id,
ES256.from_cryptography_key(self.private_key.public_key()))

def create(self, options, origin):
def create(self, options: Union[CredentialCreationOptions, Dict], origin: str):
"""create credential and return PublicKeyCredential object aka attestation"""

if {'alg': -7, 'type': 'public-key'} not in options['publicKey']['pubKeyCredParams']:
Expand Down Expand Up @@ -90,7 +91,7 @@ def create(self, options, origin):
'type': 'public-key'
}

def get(self, options, origin):
def get(self, options: Union[CredentialRequestOptions, Dict], origin: str):
"""get authentication credential aka assertion"""

if self.rp_id != options['publicKey']['rpId']:
Expand Down

0 comments on commit 204628c

Please sign in to comment.