Skip to content

Commit

Permalink
Move CredentialDeviceType into structs
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKale committed Jun 30, 2022
1 parent 631b3e7 commit e222bf6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
16 changes: 1 addition & 15 deletions webauthn/helpers/parse_backup_flags.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
from enum import Enum
from pydantic import BaseModel

from .structs import AuthenticatorDataFlags
from .structs import AuthenticatorDataFlags, CredentialDeviceType
from .exceptions import InvalidBackupFlags


class CredentialDeviceType(str, Enum):
"""A determination of the number of devices a credential can be used from
Members:
`SINGLE_DEVICE`: A credential that is bound to a single device
`MULTI_DEVICE`: A credential that can be used from multiple devices (e.g. passkeys)
https://w3c.github.io/webauthn/#sctn-credential-backup (L3 Draft)
"""

SINGLE_DEVICE = "single_device"
MULTI_DEVICE = "multi_device"


class ParsedBackupFlags(BaseModel):
credential_device_type: CredentialDeviceType
credential_backed_up: bool
Expand Down
22 changes: 22 additions & 0 deletions webauthn/helpers/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def _validate_bytes_fields(cls, v, field: ModelField):
# values
return v


################
#
# Fundamental data structures
Expand Down Expand Up @@ -545,3 +546,24 @@ class AuthenticationCredential(WebAuthnBaseModel):
type: Literal[
PublicKeyCredentialType.PUBLIC_KEY
] = PublicKeyCredentialType.PUBLIC_KEY


################
#
# Credential Backup State
#
################


class CredentialDeviceType(str, Enum):
"""A determination of the number of devices a credential can be used from
Members:
`SINGLE_DEVICE`: A credential that is bound to a single device
`MULTI_DEVICE`: A credential that can be used from multiple devices (e.g. passkeys)
https://w3c.github.io/webauthn/#sctn-credential-backup (L3 Draft)
"""

SINGLE_DEVICE = "single_device"
MULTI_DEVICE = "multi_device"

0 comments on commit e222bf6

Please sign in to comment.