[SecureContext] interface WebAuthentication {
    Promise < ScopedCredentialInfo > makeCredential (
        Account                                 accountInformation,
        sequence < ScopedCredentialParameters > cryptoParameters,
        BufferSource                            attestationChallenge,
        optional ScopedCredentialOptions        options
    );

    Promise < WebAuthnAssertion > getAssertion (
        BufferSource               assertionChallenge,
        optional AssertionOptions  options
    );
};

[SecureContext]
interface ScopedCredentialInfo {
    readonly attribute ScopedCredential     credential;
    readonly attribute CryptoKey            publicKey;
    readonly attribute WebAuthnAttestation  attestation;
};

dictionary Account {
    required DOMString rpDisplayName;
    required DOMString displayName;
    required DOMString id;
    DOMString          name;
    DOMString          imageURL;
};

dictionary ScopedCredentialParameters {
    required ScopedCredentialType  type;
    required AlgorithmIdentifier   algorithm;
};

dictionary ScopedCredentialOptions {
    unsigned long                             timeoutSeconds;
    USVString                                 rpId;
    sequence < ScopedCredentialDescriptor >  excludeList;
    WebAuthnExtensions                        extensions;
};

[SecureContext]
interface WebAuthnAssertion {
    readonly attribute ScopedCredential  credential;
    readonly attribute ArrayBuffer       clientData;
    readonly attribute ArrayBuffer       authenticatorData;
    readonly attribute ArrayBuffer       signature;
};

dictionary AssertionOptions {
    unsigned long                            timeoutSeconds;
    USVString                                rpId;
    sequence < ScopedCredentialDescriptor > allowList;
    WebAuthnExtensions                       extensions;
};

dictionary WebAuthnExtensions {
};

[SecureContext]
interface WebAuthnAttestation {
    readonly    attribute USVString     format;
    readonly    attribute ArrayBuffer   clientData;
    readonly    attribute ArrayBuffer   authenticatorData;
    readonly    attribute any           attestation;
};

dictionary ClientData {
    required DOMString           challenge;
    required DOMString           origin;
    required AlgorithmIdentifier hashAlg;
    DOMString                    tokenBinding;
    WebAuthnExtensions           extensions;
};

enum ScopedCredentialType {
    "ScopedCred"
};

[SecureContext]
interface ScopedCredential {
    readonly attribute ScopedCredentialType type;
    readonly attribute ArrayBuffer          id;
};

dictionary ScopedCredentialDescriptor {
    required ScopedCredentialType type;
    required BufferSource   id;
    sequence < Transport >  transports;
};

enum Transport {
    "usb",
    "nfc",
    "ble"
};